basic

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2023 License: Apache-2.0 Imports: 19 Imported by: 8

Documentation

Overview

Package basic gives a default implementation of the Engine interface. It only connects to local forwarding node via Unix socket.

Index

Constants

View Source
const DefaultInterestLife = 4 * time.Second
View Source
const TimeoutMargin = 10 * time.Millisecond

Variables

This section is empty.

Functions

func NewTimer

func NewTimer() ndn.Timer

Types

type Engine

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

func NewEngine

func NewEngine(face Face, timer ndn.Timer, cmdSigner ndn.Signer, cmdChecker ndn.SigChecker) *Engine

func (*Engine) AttachHandler

func (e *Engine) AttachHandler(prefix enc.Name, handler ndn.InterestHandler) error

func (*Engine) DetachHandler

func (e *Engine) DetachHandler(prefix enc.Name) error

func (*Engine) EngineTrait

func (e *Engine) EngineTrait() ndn.Engine

func (*Engine) Express

func (e *Engine) Express(
	finalName enc.Name, config *ndn.InterestConfig, rawInterest enc.Wire, callback ndn.ExpressCallbackFunc,
) error

func (*Engine) RegisterRoute

func (e *Engine) RegisterRoute(prefix enc.Name) error

func (*Engine) Shutdown

func (e *Engine) Shutdown() error

func (*Engine) Spec

func (*Engine) Spec() ndn.Spec

func (*Engine) Start

func (e *Engine) Start() error

func (*Engine) Timer

func (e *Engine) Timer() ndn.Timer

func (*Engine) UnregisterRoute

func (e *Engine) UnregisterRoute(prefix enc.Name) error

type Face

type Face interface {
	Open() error
	Close() error
	Send(pkt enc.Wire) error
	IsRunning() bool
	IsLocal() bool
	SetCallback(onPkt func(r enc.ParseReader) error,
		onError func(err error) error)
}

type NameTrie

type NameTrie[V any] struct {
	// contains filtered or unexported fields
}

NameTrie is a simple implementation of a Name trie (node/subtree) used for PIT and FIB. It is slow due to the usage of String(). Subject to change when it explicitly affects performance.

func NewNameTrie

func NewNameTrie[V any]() *NameTrie[V]

NewNameTrie creates a new NameTrie and returns the root node.

func (*NameTrie[V]) Delete

func (n *NameTrie[V]) Delete()

Delete deletes the node itself. Altomatically removes the parent node if it is empty.

func (*NameTrie[V]) DeleteIf

func (n *NameTrie[V]) DeleteIf(pred func(V) bool)

DeleteIf deletes the node and its ancestors if they are empty. Whether empty or not is defined by a given function.

func (*NameTrie[V]) Depth

func (n *NameTrie[V]) Depth() int

Depth returns the depth of a node in the tree.

func (*NameTrie[V]) ExactMatch

func (n *NameTrie[V]) ExactMatch(name enc.Name) *NameTrie[V]

ExactMatch returns the node that matches the name exactly. If no node matches, it returns nil.

func (*NameTrie[V]) FirstNodeIf

func (n *NameTrie[V]) FirstNodeIf(pred func(V) bool) *NameTrie[V]

FirstNodeIf returns the first node that satisfies given condition, in DFS order.

func (*NameTrie[V]) FirstSatisfyOrNew

func (n *NameTrie[V]) FirstSatisfyOrNew(name enc.Name, pred func(V) bool) *NameTrie[V]

FirstSatisfyOrNew finds or creates the first node along the path that satisfies the predicate.

func (*NameTrie[V]) HasChildren

func (n *NameTrie[V]) HasChildren() bool

HasChildren returns whether the node has children.

func (*NameTrie[V]) MatchAlways

func (n *NameTrie[V]) MatchAlways(name enc.Name) *NameTrie[V]

MatchAlways finds or creates the node that matches the name exactly.

func (*NameTrie[V]) Parent

func (n *NameTrie[V]) Parent() *NameTrie[V]

Parent returns its parent node.

func (*NameTrie[V]) PrefixMatch

func (n *NameTrie[V]) PrefixMatch(name enc.Name) *NameTrie[V]

PrefixMatch returns the longest prefix match of the name. Always succeeds, but the returned node may be empty.

func (*NameTrie[V]) SetValue

func (n *NameTrie[V]) SetValue(value V)

SetValue puts some value in the node.

func (*NameTrie[V]) Value

func (n *NameTrie[V]) Value() V

Value returns the value stored in the node.

type StreamFace

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

func NewStreamFace

func NewStreamFace(network string, addr string, local bool) *StreamFace

func (*StreamFace) Close

func (f *StreamFace) Close() error

func (*StreamFace) IsLocal

func (f *StreamFace) IsLocal() bool

func (*StreamFace) IsRunning

func (f *StreamFace) IsRunning() bool

func (*StreamFace) Open

func (f *StreamFace) Open() error

func (*StreamFace) Run

func (f *StreamFace) Run()

func (*StreamFace) Send

func (f *StreamFace) Send(pkt enc.Wire) error

func (*StreamFace) SetCallback

func (f *StreamFace) SetCallback(onPkt func(r enc.ParseReader) error,
	onError func(err error) error)

type Timer

type Timer struct{}

func (Timer) Nonce

func (Timer) Nonce() []byte

func (Timer) Now

func (Timer) Now() time.Time

func (Timer) Schedule

func (Timer) Schedule(d time.Duration, f func()) func() error

func (Timer) Sleep

func (Timer) Sleep(d time.Duration)

type WebSocketFace added in v0.0.2

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

func NewWebSocketFace added in v0.0.2

func NewWebSocketFace(network string, addr string, local bool) *WebSocketFace

func (*WebSocketFace) Close added in v0.0.2

func (f *WebSocketFace) Close() error

func (*WebSocketFace) IsLocal added in v0.0.2

func (f *WebSocketFace) IsLocal() bool

func (*WebSocketFace) IsRunning added in v0.0.2

func (f *WebSocketFace) IsRunning() bool

func (*WebSocketFace) Open added in v0.0.2

func (f *WebSocketFace) Open() error

func (*WebSocketFace) Run added in v0.0.2

func (f *WebSocketFace) Run()

func (*WebSocketFace) Send added in v0.0.2

func (f *WebSocketFace) Send(pkt enc.Wire) error

func (*WebSocketFace) SetCallback added in v0.0.2

func (f *WebSocketFace) SetCallback(onPkt func(r enc.ParseReader) error,
	onError func(err error) error)

Jump to

Keyboard shortcuts

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