Git Product home page Git Product logo

sm's Introduction

sm(shard manager)

Inspire by

We build sm to handle the backend service which need partition data into several instance(k8s pod or actual machines, use container below), the data in each container may be seen as a job. sm developed base on etcd, to make sure that:

  • When container changed, some shard moves will be made.
  • When shard changed, some shard moves will be made.
  • When shard or container load changed, shard moves(TODO).

Table of Contents

Getting Started

Installing

Install etcd, test with etcd-v3.4.13

Install go >=go1.17.1, and run:

go get https://github.com/entertainment-venue/sm/server

go mod tidy

go run main.go --config-file sample.yml

Concept explanation

Container

Container is the resource for shard to run in, and Container establish Session with etcd, the Session is used for the management of keys in etcd, management meaning that:

  • Container goes down, heartbeat which from container to etcd server will be ended.
  • Only the unchanged properties of app or shard will stay in etcd permanently, make data to be managed as clean as the moonlight.

Container also define common protocol which need sharded application who want to integrate with sm:

type ShardInterface interface {
	Add(id string, spec *ShardSpec) error
	Drop(id string) error
}

You can implement the ShardInterface and inject the implementation into the Container with WithShardImplementation, and also wrap common http api to interact with the sm server. The keep http path:

  • /sm/admin/add-shard
  • /sm/admin/drop-shard

For more information, you can read the source code for Container.

Example

You can see the test code as tip to understand how to construct you own sharded application:

https://github.com/entertainment-venue/sm/blob/main/client/client_test.go#L13

If you want to no better how the sm server running, see the code below as an entry point:

https://github.com/entertainment-venue/sm/blob/main/server/main.go

Question

Please feel free to report any issue or optimization suggestion in Issues

sm's People

Contributors

bearbearkeeper avatar wkwen avatar zd3tl avatar

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.