Documentation ¶
Overview ¶
Package ident contains types that represent various Rinq identifiers.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MustValidate ¶
func MustValidate(v validatable)
MustValidate panics if v.Validate() returns an error.
Types ¶
type MessageID ¶
MessageID uniquely identifies a message that originated from a session.
func ParseMessageID ¶
ParseMessageID parses a string representation of a message ID.
func (MessageID) ShortString ¶
ShortString returns a string representation based on the session's short string representation.
type PeerID ¶
type PeerID struct { // Clock is a time-based portion of the ID, this helps uniquely identify // peer IDs over longer time-scales, such as when looking back through // logs, etc. Clock uint64 // Rand is a unique number identifying this peer within a network at any // given time. It is generated randomly and then reserved when the peer // connects to the network. Rand uint16 }
PeerID uniquely identifies a peer within a network.
Peer IDs contain a clock component and a random 16-bit integer component. They are rendered in hexadecimal encoding, with a hypen separating the two components, such as "58AEE146-191C".
For a given network, the random component is guaranteed to be unique at any given time; and, assuming a stable system clock it is highly likely that the ID is unique across time. This makes peer IDs useful for tracking peer behavior in logs.
All other IDs generated by a peer, such as SessionID and MessageID are derived from the peer ID.
func NewPeerID ¶
func NewPeerID() PeerID
NewPeerID creates a new ID struct. There is no guarantee that the ID is unique until the peer is connected to a network.
func (PeerID) Session ¶
Session returns a new session ID for this peer with seq as the sequence number.
func (PeerID) ShortString ¶
ShortString returns a string representation of the peer ID without the clock component (e.g. "191C").
type Ref ¶
Ref refers to a session at a specific revision.
func (Ref) Message ¶
Message returns a new message ID derived from this ref with seq as the sequence number.
func (Ref) ShortString ¶
ShortString returns a string representation based on the session's short string representation.
type Revision ¶
type Revision uint32
Revision holds the "version" of a session. A session's revision is incremented when a change is made to its attribute table. A session that has never been modified, and hence has no attributes always has a revision of 0.
type SessionID ¶
type SessionID struct { // Peer is the ID of the peer that owns the session. Peer PeerID // Seq is a monotonically increasing sequence allocated to each session in // the order it is created by the owning peer. Application sessions begin // with a sequence value of 1. The sequnce value zero is reserved for the // "zero-session", which is used for internal operations. Seq uint32 }
SessionID uniquely identifies a session within a network.
Session IDs contain a peer component, and a 32-bit sequence component. They are rendereds as a peer ID, followed by a period, then the sequence component as a decimal, such as "58AEE146-191C.45".
Because the peer ID is embedded, the same uniqueness guarantees apply to the session ID as to the peer ID.
func ParseSessionID ¶
ParseSessionID parses a string representation of a session ID.
func (SessionID) ShortString ¶
ShortString returns a string representation of the session ID based on the peer IDs short representation (e.g. "191C.45").