-
Notifications
You must be signed in to change notification settings - Fork 1
/
swim.proto
113 lines (92 loc) · 4.54 KB
/
swim.proto
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
// Copyright (c) 2016 AlertAvert.com. All rights reserved.
// Licensed under the Apache 2 License terms.
// These are the messages that define an implemenation of the SWIM protocol.
//
// See [References](https://github.com/massenz/distlib#swim-gossip-and-consensus-algorithm)
// in the README doc.
// TODO: move to proto3 syntax.
syntax = "proto2";
package swim;
// We still want reflection and the full-fat version of Protobuf, but we can try to optimize for
// code size.
// See: https://developers.google.com/protocol-buffers/docs/reference/cpp/google.protobuf.message_lite
option optimize_for = CODE_SIZE;
// A running SWIM service is uniquely identified by the hostname:port combination.
// The optional IP address is only provided to help in those deployment where DNS
// resolution is either not available, infeasible or too expensive computationally.
message Server {
required string hostname = 1;
required int32 port = 2;
optional string ip_addr = 3;
}
// A record of an event for a given server.
message ServerRecord {
// The server this record refers to: it could either be the sender itself,
// when responding to a "ping request" from a neighbor, or the server that
// was being pinged by the `forwarder` (see below) on behalf of the receiver.
required Server server = 1;
// UTC-based UNIX time (seconds from epoch, 1/1/1970) of when this
// message was created and can be reasonably assumed (but not guaranteed)
// that it also represents the time at which `server` responded to the "ping request."
required fixed64 timestamp = 2;
// If this record is sent on behalf of another server,
// the forwarder should enter its identity here.
optional Server forwarder = 3;
}
// A status report disseminated "infection-style" via the SWIM protocol, reporting
// changes in the nodes' population status: the reporter will list newly detected (since last
// report) `suspected` nodes, as well as `alive` nodes (formerly "suspected" of being dead).
//
// The report here may not contain the full list, as in the SWIM protocol, to ensure
// constant-size messages and reduce network congestion as clusters' size grows, the size of the
// report is capped at a given max amount of servers' statuses.
//
// Each of these lists can be empty, but at least one of them SHOULD contain at
// least one element.
//
// Collectively, they will contain no more than MAX_REPORTED servers, as configured in the
// system.
//
message SwimReport {
// The sender and the time when this report was created.
required Server sender = 1;
// `alive` servers are those that were `suspected` to have crashed, but have subsequently
// been found to be healthy and responding, within the configured `SUSPECTED_TTL` time.
repeated ServerRecord alive = 3;
// These servers are suspected to have crashed (have not responded to pings recently) but
// still within the grace period, before they are declared to be `dead`.
repeated ServerRecord suspected = 4;
}
// Simple status message exchanged between servers participating in
// the SWIM protocol.
//
// For more details, see: https://goo.gl/VUn4iQ
message SwimEnvelope {
enum Type {
// This type of message is the one used by servers both during the "detection"
// phase, to 'ping' their neighbors and discover their state as well as
// by a "suspected" server to its (randomly chosen) neighbors
// to confirm its `alive` status.
//
// No payload is sent with this message.
STATUS_UPDATE = 1;
// This is used by servers to exchange status updates on the clusters.
// The payload must be a `SwimReport` message.
STATUS_REPORT = 2;
// Used by servers to request other nodes to ping the given `destination_server` on
// their behalf; more info in the SWIM protocol document.
// The payload must be `destination_server` message.
STATUS_REQUEST = 3;
}
// What type of message content will be enclosed in the "envelope"; receiving servers are
// free to simply ignore malformed messages or return error responses.
required Type type = 1;
// The server sending this envelope, which will also be assumed to be "healthy" by the
// receiver who will update its membership list accordingly.
required Server sender = 2;
optional SwimReport report = 5;
// The server that is `suspected` and should be pinged by the receiver
// on behalf of the `sender`; this is only used when used in a Type::STATUS_REQUEST
// message.
optional Server destination_server = 6;
}