layer

package
v0.67.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 21, 2021 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Base added in v0.63.0

type Base interface {
	// SetOnLayerEvent set on layer event
	SetOnLayerEvent(o OnLayerEventFn)
	// SetOnAnnounce on announce event
	SetOnAnnounce(o OnAnnounceFn)
	// SetOnRevoke on revoke event
	SetOnRevoke(o OnAnnounceFn)
	// RegisterAboveLayer above layer events with current layer
	// must be done here since announce nexus
	// is not available form base layer
	RegisterAboveLayer(belowLayer Base)
	// RegisterLayerEvent layer event with nexuses
	RegisterLayerEvent(fn OnLayerEventFn, layerName string)
	// AnnounceNexus nexusHelper
	AnnounceNexus(belowNexus nexusHelper.Nexus)
	// TrackNexus nexusHelper events
	TrackNexus(nexus nexusHelper.Nexus, belowNexus nexusHelper.Nexus)
	// UntrackNexus remove's tracker from nexusHelper events
	UntrackNexus(nexus nexusHelper.Nexus, belowNexus nexusHelper.Nexus)
	// TrackNexusAnnounced tracks that a nexus has been announced
	TrackNexusAnnounced(nexus nexusHelper.Nexus)
	// IsNexusAnnounced checks wether or not a nexus has been announced
	IsNexusAnnounced(nexus nexusHelper.Nexus) bool
	// RevokeNexus revokes a nexus
	RevokeNexus(belowNexus nexusHelper.Nexus)
}

Base is the base class for all layers.

type BaseLayer

type BaseLayer struct {
	// LayerName is the name of the current layer this is
	// a string rather than a method call to make debugging easier
	LayerName string
	// OnLayerEvent is a nullable function to be called when a layer
	// event occurs
	OnLayerEvent OnLayerEventFn
	// OnAnnounce is called when a nexus is announced to the layer (from below)
	OnAnnounce OnAnnounceFn
	// OnRevoke is called when a nexus is revoked from the layer (from below)
	OnRevoke OnRevokeFn
	// Nexuses is a thread-safe map of Nexuses to their ids uuid[nexus]
	Nexuses NexusMap
	// Announced is a thread-safe map of Nexuses to their ids uuid[nexus]
	Announced NexusMap
	// BelowNexuses is a thread-safe map of BelowNexuses to their ids uuid[nexus]
	BelowNexuses NexusMap
	// NexusByBelow is a map of below nexuses by nexus[uuid]
	NexusByBelow NexusUUIDMap
	// BelowByNexus is a map of nexus->uuid
	BelowByNexus NexusUUIDMap
}

BaseLayer is used as a superclass for layers.

func NewBaseLayer

func NewBaseLayer() BaseLayer

NewBaseLayer creates a new base layer, note you still have to call register_above nexus.

func (*BaseLayer) IsNexusAnnounced

func (l *BaseLayer) IsNexusAnnounced(nexus nexusHelper.Nexus) bool

IsNexusAnnounced determines wether or not a given nexus has been announced.

func (*BaseLayer) RegisterLayerEvent

func (l *BaseLayer) RegisterLayerEvent(fn OnLayerEventFn, layerName string)

RegisterLayerEvent registers the layer event.

func (*BaseLayer) RevokeNexus

func (l *BaseLayer) RevokeNexus(belowNexus nexusHelper.Nexus)

RevokeNexus removes the nexus from directories/layers.

func (*BaseLayer) SendLayerEvent

func (l *BaseLayer) SendLayerEvent(nexus nexusHelper.Nexus, status string)

SendLayerEvent sends an event up the chain.

func (*BaseLayer) SetOnAnnounce

func (l *BaseLayer) SetOnAnnounce(o OnAnnounceFn)

SetOnAnnounce sets an on announce function.

func (*BaseLayer) SetOnLayerEvent

func (l *BaseLayer) SetOnLayerEvent(o OnLayerEventFn)

SetOnLayerEvent sets the layer event.

func (*BaseLayer) SetOnRevoke

func (l *BaseLayer) SetOnRevoke(o OnRevokeFn)

SetOnRevoke sets the revoke callback.

func (*BaseLayer) TrackNexus

func (l *BaseLayer) TrackNexus(nexus nexusHelper.Nexus, belowNexus nexusHelper.Nexus)

TrackNexus trackers the nexus.

func (*BaseLayer) TrackNexusAnnounced

func (l *BaseLayer) TrackNexusAnnounced(nexus nexusHelper.Nexus)

TrackNexusAnnounced tracks the nexus.

func (*BaseLayer) TrackNexusRevoked

func (l *BaseLayer) TrackNexusRevoked(nexus nexusHelper.Nexus)

TrackNexusRevoked tracks that a nexus has been revoked.

func (*BaseLayer) UntrackNexus

func (l *BaseLayer) UntrackNexus(nexus nexusHelper.Nexus, belowNexus nexusHelper.Nexus)

UntrackNexus untracks the nexus.

type NexusMap

type NexusMap struct {
	// contains filtered or unexported fields
}

NexusMap that enforces types TODO this should get replaced with a string map.

func (*NexusMap) Delete

func (nm *NexusMap) Delete(nexusUUID uuid.UUID)

Delete deletes an item from a map.

func (*NexusMap) Get

func (nm *NexusMap) Get(nexusUUID uuid.UUID) (nexusHelper.Nexus, bool)

Get a nexus from the map, don't check for key presence.

func (*NexusMap) Range

func (nm *NexusMap) Range(f func(key uuid.UUID, nexus nexusHelper.Nexus) bool)

Range loops through a nexus map.

func (*NexusMap) Store

func (nm *NexusMap) Store(nexusUUID uuid.UUID, nexus nexusHelper.Nexus)

Store idempotently add an nexus to map.

type NexusStringMap

type NexusStringMap struct {
	// contains filtered or unexported fields
}

NexusStringMap is a nexus map that enforces types.

func (*NexusStringMap) Delete

func (num *NexusStringMap) Delete(key string)

Delete an item from a map.

func (*NexusStringMap) Get

func (num *NexusStringMap) Get(key string) (nexusHelper.Nexus, bool)

Get a nexus from the map, don't check for key presence.

func (*NexusStringMap) Range

func (num *NexusStringMap) Range(f func(key string, value nexusHelper.Nexus) bool)

Range loops through a NexusStringMap.

func (*NexusStringMap) Store

func (num *NexusStringMap) Store(key string, nexus nexusHelper.Nexus)

Store idempotently adds an item to map.

type NexusUUIDMap added in v0.54.0

type NexusUUIDMap struct {
	// contains filtered or unexported fields
}

NexusUUIDMap is the nexus map that enforces types.

func (*NexusUUIDMap) Delete added in v0.54.0

func (num *NexusUUIDMap) Delete(nexusUUID uuid.UUID)

Delete an item from a map.

func (*NexusUUIDMap) Get added in v0.54.0

func (num *NexusUUIDMap) Get(nexusUUID uuid.UUID) (uuid.UUID, bool)

Get a nexus from the map, don't check for key presence.

func (*NexusUUIDMap) Range added in v0.54.0

func (num *NexusUUIDMap) Range(f func(key uuid.UUID, value uuid.UUID) bool)

Range iterates through a NexusUUIDMap.

func (*NexusUUIDMap) Store added in v0.54.0

func (num *NexusUUIDMap) Store(nexusUUID uuid.UUID, nexus uuid.UUID)

Store idempotently add an idea to map.

type OnAnnounceFn

type OnAnnounceFn = func(nexus nexusHelper.Nexus)

OnAnnounceFn is the announce function for the nexus.

type OnLayerEventFn

type OnLayerEventFn = func(layerName string, nexus nexusHelper.Nexus, event string)

OnLayerEventFn is a function downstream layers call on an event.

type OnRevokeFn

type OnRevokeFn = func(nexus nexusHelper.Nexus)

OnRevokeFn is the revoke function for the nexus.

type UnknownNexus

type UnknownNexus struct{}

UnknownNexus is a non-existent nexus that allows us to avoid returning a null value.

func NewUnknownNexus

func NewUnknownNexus() UnknownNexus

nolint

func (UnknownNexus) GetDownwardNexusList

func (u UnknownNexus) GetDownwardNexusList() []nexus.Nexus

nolint

func (UnknownNexus) InitiateClose

func (u UnknownNexus) InitiateClose()

nolint

func (UnknownNexus) IsEqual

func (u UnknownNexus) IsEqual(n nexus.Nexus) bool

nolint

func (UnknownNexus) Name

func (u UnknownNexus) Name() string

nolint

func (UnknownNexus) OnBinMessage

func (u UnknownNexus) OnBinMessage(belowNexus nexus.Nexus, msg []byte)

nolint

func (UnknownNexus) OnMessage

func (u UnknownNexus) OnMessage(belowNexus nexus.Nexus, msg base.MoneysocketMessage)

nolint

func (UnknownNexus) Send

nolint

func (UnknownNexus) SendBin

func (u UnknownNexus) SendBin(msg []byte) error

nolint

func (UnknownNexus) SetOnBinMessage

func (u UnknownNexus) SetOnBinMessage(messageBinFunc nexus.OnBinMessage)

nolint

func (UnknownNexus) SetOnMessage

func (u UnknownNexus) SetOnMessage(messageFunc nexus.OnMessage)

nolint

func (UnknownNexus) SharedSeed

func (u UnknownNexus) SharedSeed() *beacon.SharedSeed

nolint

func (UnknownNexus) UUID added in v0.53.0

func (u UnknownNexus) UUID() uuid.UUID

nolint

Directories

Path Synopsis
Package compat provides interfaces for nexuses imported by a lyer to avoid circular imports
Package compat provides interfaces for nexuses imported by a lyer to avoid circular imports

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL