Skip to content

Commit

Permalink
add a few notes around restructuring
Browse files Browse the repository at this point in the history
  • Loading branch information
KodrAus committed Nov 7, 2016
1 parent 078cc0d commit 18ade66
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
3 changes: 3 additions & 0 deletions src/client/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ impl ClientBuilder {
let addrs = self.addrs;
let mut client = self.client;

// TODO: Instead of adding machines here, add them to the context
// Then add a single MasterMachine
// This MasterMachine will spawn ConnectionMachines from the context
thread::spawn(move || {
let creator = Loop::new(&Config::new()).unwrap();
let mut pool = creator.instantiate(Context);
Expand Down
14 changes: 12 additions & 2 deletions src/client/fsm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,20 @@ This way, when a connection needs to be respawned, we don't have to try and chan
So it'll be more like the sniffed pool, just without an external source of truth
This means the only notifier the Handler has is one to the wakeup machine.
It also opens the door for only waking up machines that aren't currently busy or for doing other match logic
In that case though, we'd need to put connection machines on separate queues
In that case though, we'd need to put connection machines on separate queues.
Or use a work stealing queue.
It would be neat to look at using a message hash to route to a particular machine that in turn is connected to a
particular Elasticsearch node.
*/

#[doc(hidden)]
pub struct Context;

// TODO: Add an Fsm that joins MasterMachine and ConnectionMachine

// TODO: Add a MasterMachine

// TODO: This becomes ConnectionMachine
/// A state machine for managing a persistent connection to an Elasticsearch node.
pub struct Fsm<'a, C> {
q: &'a Queue,
Expand All @@ -32,6 +40,8 @@ impl <'a, C> RotorClient for Fsm<'a, C> {
type Seed = &'a Queue;

fn create(seed: Self::Seed, _scope: &mut Scope<<Self::Requester as Requester>::Context>) -> Self {
// Context should contain instructions for machines to build
// Wakeup machine makes sure they match that state with Spawn responses
Fsm {
q: seed,
_c: PhantomData
Expand Down Expand Up @@ -62,6 +72,6 @@ impl <'a, C> RotorClient for Fsm<'a, C> {

fn connection_error(self, _err: &ProtocolError, _scope: &mut Scope<C>) {
//TODO: On connection error, we need to do something... The handler needs to know things have changed
unimplemented!()
panic!("unimplemented: connection error")
}
}
1 change: 1 addition & 0 deletions src/client/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ mod req;

pub use self::client::*;

// TODO: This should be an `elastic_requests` type.
/// A request message.
///
/// This is what you supply to kick off a request.
Expand Down

0 comments on commit 18ade66

Please sign in to comment.