noria-mysql icon indicating copy to clipboard operation
noria-mysql copied to clipboard

adding LocalAuthority as an option for a client-server model

Open rrichardson opened this issue 6 years ago • 3 comments
trafficstars

This is a proposal for how to manage configuring a client with the static address of a server. It builds, but I haven't tested it. I want to make sure this is a sane approach before I go further.

I had to create a run() function so that I could statically dispatch based on the type of Authority. I was unable to Box SyncControllerHandle without editing the noria code.

rrichardson avatar Oct 23 '19 22:10 rrichardson

Ah, that's an interesting to this. I'm a little worried about constructing a LocalAuthority this way, since it's not intended to be used in this fashion. Its impl Authority assumes that everyone shares the same LocalAuthority instance. In this particular case, it doesn't matter too much, since the client doesn't actually use the Authority part for anything except "discovering" the leader, but it's definitely an abuse of the API that might bite us later. I wonder whether a better approach here would be to write a new type, DirectClientAuthority, which implements Authority but is constructed by giving a controller address, yields that address when asked, and apart from that returns panic!("DirectClientAuthority can only be used by Noria clients, not by workers").

jonhoo avatar Oct 24 '19 15:10 jonhoo

@jonhoo - I agree that using LocalAuthority in this way is an abuse. It was suggested in the ticket that there be a ConfigAuthority which makes a bit of sense.. it would be a read-only authority.

What about breaking the Authority trait into two traits:

  1. An "authority" (Readable) portion.
  2. A "collaborator" portion.. involving the elections and consensus.

So the ZookeeperAuthority struct would actually implement both, but the ConfigAuthority would only implement the read portion (being directly initialized with a Map of some sort )

rrichardson avatar Oct 24 '19 23:10 rrichardson

Sure, that seems like a reasonable way to do it. Maybe Discover (for finding the controller) and Participate (for becoming a worker)?

jonhoo avatar Oct 25 '19 12:10 jonhoo