A Go implementation of Apache Helix.
Currently the participant part only, compatible with the Apache Helix Java controller.
go get -u github.com/uber-go/go-helix
participant, fatalErrChan := NewParticipant(
zap.NewNop(),
tally.NoopScope,
"localhost:2181", // Zookeeper connect string
"test_app", // application identifier
"test_cluster", // helix cluster name
"test_resource", // helix resource name
"localhost", // participant host name
123, // participant port
)
processor := NewStateModelProcessor()
processor.AddTransition("OFFLINE", "ONLINE", func(m *model.Message) (err error) {
partitionNum, err := p.getPartitionNum(m)
if err != nil {
return err
}
// add logic here to save the owned partition and/or perform any actions for going online
})
processor.AddTransition("ONLINE", "OFFLINE", func(m *model.Message) (err error) {
partitionNum, err := p.getPartitionNum(m)
if err != nil {
return err
}
// add logic here to remove the owned partition and/or perform any actions for going offline
})
participant.RegisterStateModel("OnlineOffline", processor)
err := participant.Connect() // initialization is complete if err is nil
// listen to the fatal error channel and handle the error by
// 1. recreate participant from scratch and connect, or
// 2. quit the program and restart
fatalErr := <- fatalErrChan
Use the saved partitions to see if the partition should be handled by the participant.
participant.Disconnect()
The APIs are functional. We do not expect, but there's no guarantee that no breaking changes will be made.
We encourage and support an active, healthy community of contributors — including you! Details are in the contribution guide and the code of conduct. The go-helix maintainers keep an eye on issues and pull requests, but you can also report any negative conduct to [email protected]. That email list is a private, safe space; even the go-helix maintainers don't have access, so don't hesitate to hold us to a high standard.
Released under the MIT License.