Skip to content

SunLink

SunLink is a lightweight ZooKeeper replacement, built as an embeddable in-process library. It speaks the ZooKeeper wire protocol on top of an Apache Ratis Raft core, so every service gets leader election, locks and membership without a separate ZooKeeper cluster.

SunLink logo

What SunLink is

An in-process Kotlin library that implements the ZooKeeper protocol over Apache Ratis and bundles Apache Curator.

How it benefits you

Leader election, locks and peer discovery come built in, with no extra ZooKeeper cluster to run, patch or secure.

How it works

Each service’s three replicas form their own Raft ring on port 7480. Curator connects to SunLink on 127.0.0.1:2181 and runs its standard recipes.

The ZooKeeper protocol, embedded

SunLink implements the ZooKeeper wire protocol, mapped onto an Apache Ratis state machine, inside the service’s own process.

  • Persistent, ephemeral and sequential znodes.
  • Sessions with timeouts; a session’s ephemeral nodes are deleted when it expires.
  • One-shot watches.
  • Operations: create, delete, exists, getData, setData, getChildren and multi.

Consistent by construction

Writes are linearizable and reads are served from the leader, on a proven Raft core rather than a hand-written consensus algorithm.

  • A ring is per service; a quorum is 2 of 3 replicas.

Curator recipes out of the box

Apache Curator is included and connected to 127.0.0.1:2181, with enough coverage for LeaderLatch, LeaderSelector, InterProcessMutex and ServiceDiscovery.

A small Kotlin API

Start SunLink, ask whether this replica is the leader, take a lock for a block of work, and list or watch the live members.

  • leaderLatch(path), withLock(path, timeout) { ... }, members(), onMembershipChange { ... } and isLeader.

Membership and discovery

Peers are found from the StatefulSet headless-service DNS (<svc>-0.<svc>, <svc>-1.<svc>, <svc>-2.<svc>), or from an explicit <SVC>_SUNLINK_CLUSTER list.

  • SeaWave uses SunLink membership to find its replication peers.

Get SunLink

Source code, compiled builds are on the Downloads page.