Documentation ¶
Index ¶
- Constants
- type Event
- type EventList
- func (el *EventList) Filter(predicate func(event Event) bool) *EventList
- func (el *EventList) Head(n int) *EventList
- func (el *EventList) Iterator() *EventListIterator
- func (el *EventList) Len() int
- func (el *EventList) PushBack(event Event) *EventList
- func (el *EventList) PushBackList(newEvents *EventList) *EventList
- func (el *EventList) PushBackSlice(events []Event) *EventList
- func (el *EventList) RemoveFront(n int) int
- func (el *EventList) Slice() []Event
- type EventListIterator
- type Message
- type ModuleID
- type NodeAddress
- type NodeID
- type RawData
- type RawMessage
- type RetentionIndex
- type Serializable
Constants ¶
const Separator = "/"
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Event ¶
type Event interface { // Src returns the module that emitted the event. // While this information is not always necessary for the system operation, // it is useful for analyzing event traces and debugging. Src() ModuleID // NewSrc returns a new Event that has the given source module // and is otherwise identical to the original event. NewSrc(newSrc ModuleID) Event // Dest returns the destination module of the event. Dest() ModuleID // NewDest returns a new Event that has the given destination module // and is otherwise identical to the original event. NewDest(newDest ModuleID) Event // ToBytes returns a serialized representation of the event // as a slice of bytes from which the event can be reconstructed. // Note that ToBytes does not necessarily guarantee the output to be deterministic. // Even multiple subsequent calls to ToBytes on the same event object might return different byte slices. // If an error occurs during serialization, ToBytes returns a nil byte slice and a non-nil error. ToBytes() ([]byte, error) // ToString returns a human-readable representation of the event. // While not used by the runtime itself, it can be used by associated tools. // Conventionally, this representation is JSON. ToString() string }
type EventList ¶
type EventList struct {
// contains filtered or unexported fields
}
EventList represents a list of Events, e.g. as produced by a module.
func EmptyList ¶
func EmptyList() *EventList
EmptyList returns an empty EventList. TODO: consider passing EventList by value here and everywhere else.
func (*EventList) Filter ¶
Filter returns a new event list containing only those items for which predicate returns true.
func (*EventList) Head ¶
Head returns the first up to n events in the list as a new list. The original list is not modified.
func (*EventList) Iterator ¶
func (el *EventList) Iterator() *EventListIterator
Iterator returns a pointer to an EventListIterator object used to iterate over the events in this list, starting from the beginning of the list.
func (*EventList) PushBack ¶
PushBack appends an event to the end of the list. Returns the EventList itself, for the convenience of chaining multiple calls to PushBack.
func (*EventList) PushBackList ¶
PushBackList appends all events in newEvents to the end of the current EventList.
func (*EventList) PushBackSlice ¶
PushBackSlice appends all events in newEvents to the end of the current EventList.
func (*EventList) RemoveFront ¶
RemoveFront removes the first up to n events from the list. Returns the number of events actually removed.
func (*EventList) Slice ¶
Slice returns a slice representation of the current state of the list. The returned slice only contains pointers to the events in this list, no deep copying is performed. Any modifications performed on the events will affect the contents of both the EventList and the returned slice.
type EventListIterator ¶
type EventListIterator struct {
// contains filtered or unexported fields
}
EventListIterator is an object returned from EventList.Iterator used to iterate over the elements (Events) of an EventList using the iterator's Next method.
func (*EventListIterator) Next ¶
func (eli *EventListIterator) Next() Event
Next will return the next Event until the end of the associated EventList is encountered. Thereafter, it will return nil.
type Message ¶
Message represents a message to be sent over the network. It is the data type of the stdevents.SendMessage.Payload and stdevents.MessageReceived.Payload. The only requirement of a Message is that it must be serializable. Note that while a stdevents.SendMessage event as well as a stdevents.MessageReceived event can contain an arbitrary implementation of this interface in their Payload fields, a SendMessage or a MessageReceived event that underwent serialization and deserialization will always contain the RawMessage implementation of this interface, only holding the serialized representation of the original message. This is because Mir does not by itself know how to deserialize arbitrary (application-specific) messages.
type ModuleID ¶
type ModuleID string
ModuleID represents an identifier of a module. The intention is for it to correspond to a path in the module hierarchy. However, technically, the Mir Node only cares for the ID's prefix up to the first separator and ignores the rest. The rest of the ID can be used for any module-specific purposes.
func (ModuleID) Sub ¶
Sub returns the identifier of a submodule within the top-level module, stripped of the top-level module identifier.
type NodeAddress ¶
type NodeAddress multiaddr.Multiaddr
NodeAddress represents the address of a node.
func NodeAddressFromString ¶
func NodeAddressFromString(addrString string) (NodeAddress, error)
type NodeID ¶
type NodeID string
NodeID represents the ID of a node.
func NewNodeIDFromInt ¶
func NodeIDSlice ¶
NodeIDSlice converts a slice of NodeIDs represented directly as their underlying native type to a slice of abstractly typed node IDs.
type RawData ¶
type RawData []byte
RawData represents raw data contained in a deserialized event. When an event from the stdevents package undergoes serialization and deserialization, application-specific data types (represented by the Serializable type) are represented as RawData. In this form, they are handed over to application-specific code which is responsible for its deserialization.
type RawMessage ¶
type RawMessage RawData
RawMessage is technically just raw data (RawData). We use a separate type to distinguish data that is intended to be sent/received over the network from data that is generated and used locally. The difference is important for making assumptions on the consistency / correctness of the data.
func (RawMessage) ToBytes ¶
func (rm RawMessage) ToBytes() ([]byte, error)
ToBytes just delegates the call to the underlying type.
type RetentionIndex ¶
type RetentionIndex uint64
RetentionIndex represents an abstract notion of system progress used in garbage collection. The basic idea is to associate various parts of the system (parts of the state, even whole modules) that are subject to eventual garbage collection with a retention index. As the system progresses, the retention index monotonically increases and parts of the system associated with a lower retention index can be garbage-collected.
type Serializable ¶
Serializable is the type used for certain application-specific objects included in some standard events (stdevents). For example, the parameters to a submodule are required to be serializable. When deserializing events from the stdevents package, such objects will deserialize to RawData.