Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
ring-election
Advanced tools
Readme
Is your dream to build a service like cassandra,kafka,zipkin,jaeger,redis,etc...? You are in the right place , join ring-election project !!!
docker-compose up
Check assigned partitions to local:9000/status or change the port to 9001/9002
Try to stop and restart container and observe the behaviour.
If you want to develop new features or fix a bug you can do that without docker images , just configure environment variables correctly ( you can see them on [docker-compose.yaml] file) .
See Examples section to know how to integrate this library and build some distributed services on top of ring-election !!!
What the ring-election driver offers you ?
What problems can you solve with this driver ?
This section introduce you on what you can build on top of ring-election using it as driver/library.
Distributed Scheduler
Each Scheduler instance will work on the assigned partitions .
A real implementation of this use case is available here https://github.com/pioardi/hurricane-scheduler
Distributed lock
Distributed cache
Distributed computing
const ring = require('ring-election');
let leader = ring.leader;
leader.createServer();
// if you want REST API as monitoring , invoke startMonitoring
leader.startMonitoring();
// to get ring info
ring.leader.ring();
// Your leader will be the coordinator.
How to follower
const ring = require('ring-election')
let follower = ring.follower
const {
BECOME_LEADER,
PARTITIONS_ASSIGNED,
PARTITIONS_REVOKED
} = ring.constants;
follower.createClient()
// if you want REST API as monitoring , invoke startMonitoring
follower.startMonitoring()
// to get ring info
ring.follower.ring()
// to get assigned partitions
let assignedPartitions = ring.follower.partitions()
// now let me assume that a follower will create some data
// and you want to partition this data
let partition = ring.follower.defaultPartitioner('KEY')
// save your data including the partition on a storage
// you will be the only one in the cluster working on the partitions assigned to you.
// If you want to handle partitions assigned ( use other constants to listen other events ) you can do in this way.
ring.follower.eventListener.on(PARTITIONS_ASSIGNED , (newAssignedPartitions) => {
// DO STUFF
})
Try it out !
docker image build -t ring-election .
docker-compose up
See examples folder for more advanced examples
Re-add a client in the cluster when it was removed and send an hearth beat
Implement event emitter to notify library users when something happens
FAQs
Leader and followers algorithm to make partitioning easy.
The npm package ring-election receives a total of 4 weekly downloads. As such, ring-election popularity was classified as not popular.
We found that ring-election demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.