Giter VIP home page Giter VIP logo

go-helix's Introduction

go-helix GoDoc Build Status Coverage Status

A Go implementation of Apache Helix.

Currently the participant part only, compatible with the Apache Helix Java controller.

Installation

go get -u github.com/uber-go/go-helix

Quick Start

Init participant

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 participant

Use the saved partitions to see if the partition should be handled by the participant.

Disconnect participant

participant.Disconnect()

Development Status: Beta

The APIs are functional. We do not expect, but there's no guarantee that no breaking changes will be made.

Contributing

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.

go-helix's People

Contributors

david-hong avatar yulunli avatar zhijinli avatar zhixinwen avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

go-helix's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.