-
Notifications
You must be signed in to change notification settings - Fork 242
/
Copy pathcoordination.rs
67 lines (60 loc) · 1.83 KB
/
coordination.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
use dataflow::prelude::*;
use dataflow::DomainBuilder;
use noria::consensus::Epoch;
use std::collections::HashMap;
use std::net::SocketAddr;
/// Coordination-layer message wrapper; adds a mandatory `source` field to each message.
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct CoordinationMessage {
/// The worker's `SocketAddr` from which this message was sent.
pub source: SocketAddr,
/// The epoch this message is associated with.
pub epoch: Epoch,
/// Message payload.
pub payload: CoordinationPayload,
}
/// Coordination-layer message payloads.
#[derive(Clone, Debug, Deserialize, Serialize)]
pub enum CoordinationPayload {
/// Register a new worker.
Register {
/// Address of the worker.
addr: SocketAddr,
/// Address the worker will be listening on to serve reads.
read_listen_addr: SocketAddr,
/// Which log files are stored locally on the worker.
log_files: Vec<String>,
},
/// Worker going offline.
Deregister,
/// Worker is still alive.
Heartbeat,
/// Assign a new domain for a worker to run.
AssignDomain(DomainBuilder),
/// Remove a running domain from a worker.
RemoveDomain,
/// Domain connectivity gossip.
DomainBooted(DomainDescriptor),
/// Create a new security universe.
CreateUniverse(HashMap<String, DataType>),
}
#[derive(Clone, Copy, Debug, Deserialize, Serialize)]
pub struct DomainDescriptor {
id: DomainIndex,
shard: usize,
addr: SocketAddr,
}
impl DomainDescriptor {
pub fn new(id: DomainIndex, shard: usize, addr: SocketAddr) -> Self {
DomainDescriptor { id, shard, addr }
}
pub fn domain(&self) -> DomainIndex {
self.id
}
pub fn shard(&self) -> usize {
self.shard
}
pub fn addr(&self) -> SocketAddr {
self.addr
}
}