[Cluster Daemon] - Plug & Play Driver Support [part 2]

in #utopian-io3 years ago (edited)





(Source)

Introduction

Clustd is an open source cluster management provider. The goal is to provide automated failover systems for apps, whether the system is down for maintenance or an unexpected event. When the system is ready, it will deployed in production on @steemdunk to minimize any form of downtime for the bot and web services.

Disclaimer: This is not intended to be used in conjunction with a database, otherwise data will be out of sync. See your database manual for setting up clusters that will preserve the integrity of your database across multiple machines.

What does a cluster look like?

Each machine runs a clustd daemon. The daemon provides automatic consensus on deciding a new master if the master goes down. Drivers control what actions to perform when this happens.

Drivers

A driver is what controls the server when a specific machine becomes a master or is no longer a master. It does not provide its own server like a cluster daemon and connects directly to the cluster machine directly. It is expected to run alongside the cluster daemon on the same machine. Multiple drivers can connect to the cluster daemon to perform multiple actions specific to that driver.

There is now an API for driver implementations. clustd has been refactored and now has its own clustd-lib library.

A sample driver implementation

export class TestDriver extends DriverMachine {

  constructor(dc: DriverClient, host: string) {
    super(dc, host);
  }

  trigger(isMaster: boolean): void {
    console.log('Master status:', isMaster);
  }
}

Connecting to the cluster

(async () => {
  const dc: DriverClient = {
    secret: 'cluster communication secret',
    id: 'driver-test-' + crypto.randomBytes(4).readUInt32BE(0),
  }
  const dm = new BashDriver(dc, 'ws://127.0.0.1:3001');
  await dm.connect();
})();

Drivers will automatically reconnect to the cluster daemon if the daemon was taken offline. No further action is required in the implementation. The ID should always be unique in case multiple drivers of the same implementation is running. In the future this may done automatically or with a different approach and strategy.

This API is a work in progress but the initial framework is now here. This is a leap forward towards creating the bash driver.

Roadmap and ideas

The next part will have a functional bash driver. There could be additional drivers written to provide notifications, whether email or SMS. Providing a sort of monitoring framework of the cluster status and what happened.

Relevant commits

Sort:  

Hey @samrg472 I am @utopian-io. I have just upvoted you!

Achievements

  • WOW WOW WOW People loved what you did here. GREAT JOB!
  • You have less than 500 followers. Just gave you a gift to help you succeed!
  • Seems like you contribute quite often. AMAZING!

Community-Driven Witness!

I am the first and only Steem Community-Driven Witness. Participate on Discord. Lets GROW TOGETHER!

mooncryption-utopian-witness-gif

Up-vote this comment to grow my power and help Open Source contributions like this one. Want to chat? Join me on Discord https://discord.gg/Pc8HG9x

This is a great ideal if implemented

This would be great!

Thank you for the contribution. It has been approved.

You can contact us on Discord.

[utopian-moderator]

1UP-Kayrex_tiny.png

You've got upvoted by Utopian-1UP!

You can give up to ten 1UP's to Utopian posts every day after they are accepted by a Utopian moderator and before they are upvoted by the official @utopian-io account. Install the @steem-plus browser extension to use 1UP. By following the 1UP-trail using SteemAuto you support great Utopian authors and earn high curation rewards at the same time.


1UP is neither organized nor endorsed by Utopian.io!

hey rex I will be appreciated if you vote on my comment.

THANK YOU FOR THIS INCREDIBLE INFORMATION

Sam, this is excellent work you do with Utopain IO! Keep it up!

Super cool sam!

THANK YOU FOR THIS INCREDIBLE INFORMATION