-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreplica.go
More file actions
27 lines (25 loc) · 1.02 KB
/
Copy pathreplica.go
File metadata and controls
27 lines (25 loc) · 1.02 KB
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
package yin
// ReplicaID is an opaque, comparable identity for one logical CRDT replica.
//
// Consumers map their own durable identity (device, user, process, or transport
// peer) onto this value; yin neither derives nor generates ReplicaIDs. Use a
// stable, unique, non-empty ID for each logical replica. Core constructors do
// not reject an empty ID, but JSON delta and snapshot formats reject empty
// update writers, so writes issued with an empty ID cannot be encoded.
//
// ReplicaID has a deterministic total order: lexicographic byte order of the
// underlying string. That order is only for CRDT tie-breaking and does not imply
// creation time, trust, network topology, or transport identity.
type ReplicaID string
// Compare orders ReplicaIDs using their documented deterministic total order.
// It returns -1 when id sorts before other, 1 when it sorts after other, and 0
// when they are equal.
func (id ReplicaID) Compare(other ReplicaID) int {
if id < other {
return -1
}
if id > other {
return 1
}
return 0
}