Documentation ¶
Overview ¶
Package entities contains the data components of a node. A 'entity' is a unit of information like a node, neighbor or report. A entity is derived from one or multiple events. A 'table' holds the current state of all entities which is derived from the events A 'event stream' holds all events known to the node
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( //ErrEventEntityEmpty signals that the GRPC message had no TableEntity ErrEventEntityEmpty = errors.New("The event contains no entity data") )
Functions ¶
This section is empty.
Types ¶
type Event ¶
type Event interface { //Validate checks if the event message is valid //Returns true if the event is valid or false and a error containing the reason it is not Validate(*TableSet) (bool, error) //GetID returns the id of the event GetID() uuid.UUID }
Event is a change of data in a table
type EventObserver ¶
type EventObserver interface {
EventUpdate(Event)
}
EventObserver specifies a struct which can receive event updates
type EventStream ¶
type EventStream interface { //GetWriteChannel returns a channel which can be used by other components to write a new event to the stream //The EventStream is responsible for checking the validity and uniqueness of the event GetWriteChannel() chan<- Event //GetAllEvents returns all events currently in the event stream GetAllEvents() []Event //Attach can be used by other components to subscribe to updates of the event stream //The EventStream must only call the callback with validated and unique events. Attach(observerCallback EventObserver) //Detach removes a subscriber Detach(observerCallback EventObserver) //Run runs the goroutine which handles changes and requests to the EventStream Run(context.Context) error }
A EventStream holds all events known the node
func NewInMemoryEventStream ¶
func NewInMemoryEventStream(tableSet *TableSet, writeChanBufferSize int) EventStream
NewInMemoryEventStream creates a new in memory event stream
type GenericEvent ¶
type GenericEvent struct {
abusemesh.TableEvent
}
GenericEvent is a wrapper for the protocol stub
func (*GenericEvent) GetID ¶
func (event *GenericEvent) GetID() uuid.UUID
GetID returns the id of the event
type GetAllNodesRequest ¶
type GetAllNodesRequest struct { //ResponseChan is the channel over which multiple nodes will be sent ResponseChan chan<- Node //Context can be used to cancel the sending of nodes Context context.Context }
GetAllNodesRequest can be used to request all nodes from the nodes table
func (*GetAllNodesRequest) Process ¶
func (req *GetAllNodesRequest) Process(tables *TableSet) error
Process processes the request and sends a slice of nodes on the ResponseChan or nil if the node was not found
type GetNodeRequest ¶
GetNodeRequest can be used to request a specific node from a table
func (*GetNodeRequest) Process ¶
func (req *GetNodeRequest) Process(tables *TableSet) error
Process processes the request and sends a pointer to the node on the ResponseChan or nil if the node was not found
type Node ¶
type Node struct { UUID uuid.UUID ProtocolVersion string IPAddress net.IP ContactDetails abusemesh.ContactDetails ASN int32 PGPEntity *openpgp.Entity }
A Node is a node as defined by the AbuseMesh protocol[inset link to docs] with extra information internal to the node
func NodeFromProtobuf ¶
NodeFromProtobuf creates a node object from the node stub of the protobuf definition
type NodeTable ¶
A NodeTable holds the current derived state of all nodes in the network known to the current node
type TableRequest ¶
A TableRequest is request which can be made to the table set
type TableSet ¶
type TableSet struct { Channel chan TableRequest // contains filtered or unexported fields }
TableSet is a set containing all tables The TableSet has it's own goroutine which can be used to query data from the tables
func (*TableSet) EventUpdate ¶
EventUpdate creates a new update table request and queues it
type UpdateTableRequest ¶
type UpdateTableRequest struct {
Event Event
}
func (*UpdateTableRequest) Process ¶
func (req *UpdateTableRequest) Process(tables *TableSet) error