https://github.com/cakemc-network/redundant-mesh-cluster
๐ A self-repairing and mutating mesh-based cluster system built with Netty and Kotlin
https://github.com/cakemc-network/redundant-mesh-cluster
cluster clustering event-driven mesh netty networking packets redundant
Last synced: 5 months ago
JSON representation
๐ A self-repairing and mutating mesh-based cluster system built with Netty and Kotlin
- Host: GitHub
- URL: https://github.com/cakemc-network/redundant-mesh-cluster
- Owner: CakeMC-Network
- License: apache-2.0
- Created: 2025-04-12T19:34:40.000Z (about 1 year ago)
- Default Branch: develop
- Last Pushed: 2025-08-29T22:16:19.000Z (10 months ago)
- Last Synced: 2025-08-30T00:22:18.304Z (10 months ago)
- Topics: cluster, clustering, event-driven, mesh, netty, networking, packets, redundant
- Language: Kotlin
- Homepage: https://cakemc.net
- Size: 224 KB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Redundant Mesh Cluster
>A self-repairing and mutating mesh-based cluster system built with Netty and Kotlin.
## Overview
This project implements a dynamic cluster where each node can operate as either a client or a server depending on network conditions. If the main server node goes offline, the cluster autonomously promotes one of the remaining nodes to take its place, maintaining connectivity and system integrity.
### Key Features
- โ๏ธ Self-healing: Nodes detect server failure and elect a new one.
- ๐ Auto-Reconnect: Disconnected clients automatically attempt to rejoin the cluster.
- ๐ง Smart Role Assignment: Nodes dynamically decide to act as server or client based on availability.
- ๐ฆ Packet-Based Communication: Uses Netty channels and custom codecs for fast, structured messaging.
- ๐งต Multi-threaded: Built for concurrent networking and failover logic.
- ๐๏ธ Event-Driven: many out of the box events based on Client/Server behavior.
## Getting Started
```kotlin
val endpoint = Networking.createEndPoint()
endpoint.start()
endpoint.sendPacket(packet)
````
>Kill any node โ the cluster will adapt and restore itself.
## Self Repair Example:
```kotlin
val endpoint1 = Networking.createEndPoint()
val endpoint2 = Networking.createEndPoint()
val endpoint3 = Networking.createEndPoint()
val endpoint4 = Networking.createEndPoint()
thread(start = true, isDaemon = true) { endpoint1.start() }
thread(start = true, isDaemon = true) { endpoint2.start() }
thread(start = true, isDaemon = true) { endpoint3.start() }
thread(start = true, isDaemon = true) { endpoint4.start() }
Thread.sleep(5000)
println("Main: Killing endpoint1")
endpoint1.close()
```
## Event Example:
>Basic example using a Dummy Event:
```kotlin
class Event(val message: String)
fun main() {
val eventBus = EventBus()
eventBus.subscribe { event ->
println(event.message)
}
eventBus.publish(Event("TEST"))
}
```
>Networking example using events:
```kotlin
val endpoint1 = Networking.createEndPoint()
val endpoint2 = Networking.createEndPoint()
endpoint1.eventBus().subscribe { packetReceivedEvent ->
println("packet got on client 1")
println(packetReceivedEvent.packet)
if (packetReceivedEvent.packet.packetType == PacketType.REQUEST) {
endpoint2.handler().replyToPacketSync(
packetReceivedEvent.channel, packetReceivedEvent.packet,
Packet(UUID.randomUUID(), PacketType.RESPONSE, "client-1", "test", "testing", "RESPONSE")
)
}
}
endpoint2.eventBus().subscribe { packetReceivedEvent ->
println("packet got on client 2")
println(packetReceivedEvent.packet)
if (packetReceivedEvent.packet.packetType == PacketType.REQUEST) {
endpoint2.handler().replyToPacketSync(
packetReceivedEvent.channel, packetReceivedEvent.packet,
Packet(UUID.randomUUID(), PacketType.RESPONSE, "client-2", "test", "testing", "RESPONSE")
)
}
}
thread(start = true, isDaemon = true) { endpoint1.start() }
thread(start = true, isDaemon = true) { endpoint2.start() }
Thread.sleep(5000)
endpoint1.handler().sendToAllSync(
Packet(UUID.randomUUID(), PacketType.NORMAL, "client-1", "test", "testing", "{}")
)
val response = endpoint2.handler().sendPacketMainWithFuture(
Packet(UUID.randomUUID(), PacketType.REQUEST, "client-2", "test", "testing", "requesting")
).syncUninterruptedly(3000, TimeUnit.MILLISECONDS)
println("RESPONSE: " + response)
endpoint2.handler().sendToAllSync(
Packet(UUID.randomUUID(), PacketType.NORMAL, "client-2", "test", "testing", "{}")
)
val response2 = endpoint1.handler().sendPacketMainWithFuture(
Packet(UUID.randomUUID(), PacketType.REQUEST, "client-1", "test", "testing", "requesting")
).syncUninterruptedly(3000, TimeUnit.MILLISECONDS)
println("RESPONSE: " + response2)
```
---
> ๐ Built for resilience. Designed for autonomy.
> If one falls, another rises. Welcome to the future of decentralized networking.
Made with โค๏ธ by the CakeMC team.