Documentation ¶
Index ¶
- Constants
- Variables
- func FrameToProtoClearTicket(f Frame) *pb.RPCFrame
- func IsUpstream(f Frame) bool
- func IsValidShortID(x ShortID) bool
- func MetricToProto(m Metric) *pb.Metric
- func NewClientCall(identity uint64, infoStr string, ctx context.Context, memm MemoryManager) (*ClientCall, Handler)
- func NewRunningQuery() *runningQuery
- func RandHandlerID() uint64
- func ShortIDString(x ShortID) string
- type Address
- func (a Address) Append(other ...*Address) *Address
- func (a Address) Appends(other ...string) *Address
- func (a *Address) Compact() *IBList
- func (a *Address) Compare(other *Address) int
- func (a *Address) Data() string
- func (a Address) Equal(other *Address) bool
- func (a Address) Get(i int) string
- func (a Address) Iter() func() (string, bool)
- func (a Address) Len() int
- func (a Address) Slice(from, to int) *Address
- func (a Address) StartsWith(other *Address) bool
- func (a *Address) String() string
- func (a Address) ToProto() []byte
- type AnnounceFrame
- type ByteArray
- type Call
- type CancelError
- type Chunk
- type ChunkFrame
- type ClientCall
- type ClosedError
- type Core
- func (c *Core) Group() *Address
- func (c *Core) ID() *Address
- func (c *Core) Log() util.Logger
- func (c *Core) MemMan() MemoryManager
- func (c *Core) Quanda() *Quanda
- func (c *Core) QueryRoute(ctx context.Context, dest *Address, remoteQuery bool) (*Address, Handler, error)
- func (c *Core) RouteAndDispatch(ctx context.Context, frame Frame, downstreamHandler Handler) error
- func (c *Core) Router() Router
- func (c *Core) StartRPC(ctx context.Context, dest *Address, metadata []string, props map[string][]byte, ...) error
- func (c *Core) Stop()
- type DestinationEvent
- type DestinationEventListener
- type DownDataFrame
- type DownFinishFrame
- type DownResponseFrame
- type FinishError
- type Frame
- type FrameCallback
- type FrameReceiver
- type FrameSender
- type FullID
- type HalfCloseError
- type Handler
- type IBList
- type IDCollision
- type IDMismatch
- type IDUnknown
- type Identifiable
- type InitFunc
- type LinkHandler
- type Manager
- type MemoryManager
- type MemoryTicket
- type Metric
- type MultiRPCHandler
- type PrefixMapEntry
- type PrefixTreeMap
- func (ptm *PrefixTreeMap) Clear()
- func (ptm *PrefixTreeMap) Get(key *Address) interface{}
- func (ptm PrefixTreeMap) GetChildren(key *Address) (children []PrefixMapEntry)
- func (ptm PrefixTreeMap) GetNearest(key *Address) (depth int, value interface{})
- func (ptm PrefixTreeMap) GetSubtree(key *Address) (entries []PrefixMapEntry)
- func (ptm PrefixTreeMap) IterateSubtree(key *Address, action func(PrefixMapEntry) bool)
- func (ptm *PrefixTreeMap) Put(key *Address, value interface{}) (previousValue interface{})
- func (ptm *PrefixTreeMap) Remove(key *Address) (previousValue interface{})
- func (ptm PrefixTreeMap) RemoveSubtree(key *Address) (entries []PrefixMapEntry)
- func (ptm *PrefixTreeMap) Size() int
- type Quanda
- type QueryFrame
- type RPC
- type RPCNotStartedError
- type RouteMap
- func (rmap *RouteMap) Add(r Identifiable) error
- func (rmap *RouteMap) AddListener(listener DestinationEventListener)
- func (rmap *RouteMap) DestinationOffline(dest *Address, r Identifiable)
- func (rmap *RouteMap) DestinationUpdate(dest *Address, r Identifiable, metric Metric)
- func (rmap *RouteMap) Get(id uint64) Identifiable
- func (rmap *RouteMap) GetAll() (res []Identifiable)
- func (rmap *RouteMap) GetNearest(dest *Address) (int, Identifiable, Metric)
- func (rmap *RouteMap) Remove(r Identifiable) bool
- func (rmap *RouteMap) Route(dest *Address) Identifiable
- type Router
- type RoutingError
- type ServerCall
- type ServerCallFactory
- type ShortID
- type SingleRPCHandler
- type UpCancelFrame
- type UpCloseFrame
- type UpDataFrame
- type UpStartFrame
- func (t UpStartFrame) Dest() *Address
- func (t UpStartFrame) ID() ShortID
- func (t UpStartFrame) Metadata() []string
- func (t UpStartFrame) Properties() map[string][]byte
- func (t UpStartFrame) Proto() *pb.RPCFrame
- func (t UpStartFrame) Source() *Address
- func (t UpStartFrame) String() string
- func (t UpStartFrame) Type() int
Constants ¶
const ( LOff = iota // Log nothing about core and rpc operation. LInfo = iota // Log status of routes, links and names. LDetail = iota // Also log query-announce and rpc protocol events. )
Verbosity levels in logging.
const ( UpStart = 2 UpData = 3 UpClose = 4 UpCancel = 5 DownResponse = 8 DownData = 9 DownFinish = 10 )
const TokenLength uint = 0
TokenLength is the length of a token in bytes.
Variables ¶
var BlankAddress = &Address{}
BlankAddress is an address that has no parts.
var HANDLER_UNUSED_ID uint64 = 0
var LogLevel int = LInfo
LogLevel changes the amount of logged messages. It only applies when cores are being created.
Functions ¶
func FrameToProtoClearTicket ¶
func IsUpstream ¶
IsUpstream returns true if the frame goes from client to server, false if it goes from server to client (downstream)
func IsValidShortID ¶
IsValidShortID checks if the given number is a valid value for a ShortID.
func MetricToProto ¶
func NewClientCall ¶
func NewClientCall(identity uint64, infoStr string, ctx context.Context, memm MemoryManager) (*ClientCall, Handler)
func NewRunningQuery ¶
func NewRunningQuery() *runningQuery
func RandHandlerID ¶
func RandHandlerID() uint64
RandHandlerID returns a random uint64 that excludes some reserved numbers.
func ShortIDString ¶
ShortIDString returns a shortened string representation of the ShortID.
Types ¶
type Address ¶
type Address struct {
// contains filtered or unexported fields
}
Address is an immutable data structure of a sequence of segment, like parts in a filesystem path. Modifications are cheap operations without any copies by modifying and chaining slice headers. However some operations trigger compactification of all slices into a single continuous string which can be used for serialization or as a comparable map key. The compactification does not change the represented address but is a costly copy so addresses should generally be passed around as pointer so this step is done only once. Since an address is immutable, a once compacted address never becomes uncompact again.
func AddrLocal ¶
func AddrLocal() *Address
AddrLocal returns a static address prefix representing local addresses. This prefix will be substituted with the address of the local group.
func AddressFromProto ¶
func MustParseAddress ¶
MustParseAddress same as ParseAddress but panics on error.
func NewAddress ¶
NewAddress creates a new address from the given strings, each one part of the address sequence. The resulting address is compact.
func NewAddressFromData ¶
NewAddressFromData creates a new address from the given data string which must be the result from Address.Data(). The resulting address is compact and this operation is fast.
func ParseAddress ¶
ParseAddress parses a string into an address.
func (Address) Append ¶
Append returns a new address that is a concatenation of this and the other addresses. No data is copied, the result is not compact.
func (Address) Appends ¶
Appends returns a new address that is a concatenation of this and the other strings, each one address part. No data is copied, the result is not compact.
func (*Address) Compact ¶
Compact optimizes the data representation of this address into a single contigous string. Is a no-op if this address is already compact.
func (*Address) Data ¶
Data returns the raw string representation of this address. An address can be reconstructed from this string quickly without parsing. This operation compacts the address and once compacted, it is quick without further copies or string construction.
func (Address) Slice ¶
Slice returns a new address that is a sub list of this address. A 'to'-value of -1 means till the end. / No data is copied, the result is not compact.
func (Address) StartsWith ¶
func (*Address) String ¶
String returns a string of the contents of this address with an arbitrary separation character. Note that the address may not be a legal UTF-8 string and can contain arbitrary byte sequences. This operation compacts the address and once compacted, it is quick without further copies or string construction.
type AnnounceFrame ¶
type AnnounceFrame struct {
// contains filtered or unexported fields
}
func NewAnnounceFrame ¶
func NewAnnounceFrame(name *Address, metric Metric, deadline time.Time) *AnnounceFrame
func NewAnnounceFrameFromProto ¶
func NewAnnounceFrameFromProto(m *pb.Announce) *AnnounceFrame
func (*AnnounceFrame) Deadline ¶
func (f *AnnounceFrame) Deadline() time.Time
func (*AnnounceFrame) Metric ¶
func (f *AnnounceFrame) Metric() Metric
func (*AnnounceFrame) Name ¶
func (f *AnnounceFrame) Name() *Address
func (*AnnounceFrame) Proto ¶
func (f *AnnounceFrame) Proto() *pb.Announce
type CancelError ¶
type CancelError struct {
Message string
}
func (CancelError) Error ¶
func (t CancelError) Error() string
type ChunkFrame ¶
type ClientCall ¶
type ClientCall struct { Call // contains filtered or unexported fields }
func (*ClientCall) Cancel ¶
func (c *ClientCall) Cancel(message string)
func (*ClientCall) CloseSend ¶
func (c *ClientCall) CloseSend()
func (*ClientCall) Init ¶
func (c *ClientCall) Init(rpc *RPC, rcv FrameReceiver, snd FrameSender)
func (*ClientCall) Receive ¶
func (c *ClientCall) Receive() ([]byte, error)
func (*ClientCall) Send ¶
func (c *ClientCall) Send(data []byte) error
type ClosedError ¶
type ClosedError struct{}
func (ClosedError) Error ¶
func (r ClosedError) Error() string
type Core ¶
type Core struct { // TODO consider optimizing thread sync. there are also mutexes in manager and router, maybe 'm' is redundant, or the others are. // But the slow query requires a short mutex and the router but should not block the whole core. Manager // contains filtered or unexported fields }
Core is a central component of an Arpc network node. It is responsible for holding all active RPCs, all active routes, dispatching messages and resolving routes for new RPCs.
func NewCore ¶
NewCore creates a new core instance with a random core identifier suffix. This is recommended for general use.
func NewCoreExt ¶
NewCoreExt creates a new core instance with given parameters. Provides more parameterization options than NewCore.
func (*Core) Log ¶
Log returns the logger of the core. All log messages specific to a core should use this logger so logs from different cores can be distinguished in tests.
func (*Core) MemMan ¶
func (c *Core) MemMan() MemoryManager
MemMan returns the memory management module of the core.
func (*Core) QueryRoute ¶
func (c *Core) QueryRoute(ctx context.Context, dest *Address, remoteQuery bool) (*Address, Handler, error)
QueryRoute looks up a route by quering the network. It returns immediately if a route to the destination is already known at the core. Otherwise a network query is run that blocks until it times out or a solution is found. The timeout can be shortened by setting one in the provided context. If a route is found, returns the address for the found route, which may be a parent of the queried destination, and the route handler. Otherwise returns an error.
func (*Core) RouteAndDispatch ¶
RouteAndDispatch dispatches frames to their destination. If it is a start frame, a route to its destination is looked up and a local routing entry for the RPC is tracked. Returns an error if no routing entry exists for the frame, if no route can be found to the destination of a start frame or if starting the RPC fails for other reasons.
func (*Core) StartRPC ¶
func (c *Core) StartRPC(ctx context.Context, dest *Address, metadata []string, props map[string][]byte, downstreamHandler Handler) error
StartRPC starts a new RPC from this core. A route to its destination is looked up and a local routing entry for the RPC is tracked. Returns an error if no route can be found to the destination of a start frame or if starting the RPC fails for other reasons.
type DestinationEvent ¶
type DestinationEvent struct { Dest *Address Route Identifiable Metric Metric }
func (DestinationEvent) String ¶
func (e DestinationEvent) String() string
type DestinationEventListener ¶
type DestinationEventListener func(*DestinationEvent)
type DownDataFrame ¶
type DownDataFrame struct {
// contains filtered or unexported fields
}
DownDataFrame is a data chunk sent from the server to the client.
func NewDownDataFrame ¶
func NewDownDataFrame(shortID ShortID, chunk *Chunk) DownDataFrame
func (DownDataFrame) Chunk ¶
func (t DownDataFrame) Chunk() *Chunk
func (DownDataFrame) Type ¶
func (t DownDataFrame) Type() int
type DownFinishFrame ¶
type DownFinishFrame struct {
// contains filtered or unexported fields
}
DownFinishFrame is sent by the server when it completes the RPC, either regularly (status==0) or in error.
func NewDownFinishFrame ¶
func NewDownFinishFrame(shortID ShortID, status int, message string, md []string) DownFinishFrame
func (DownFinishFrame) Message ¶
func (t DownFinishFrame) Message() string
func (DownFinishFrame) Metadata ¶
func (t DownFinishFrame) Metadata() []string
func (DownFinishFrame) Status ¶
func (t DownFinishFrame) Status() int
func (DownFinishFrame) Type ¶
func (t DownFinishFrame) Type() int
type DownResponseFrame ¶
type DownResponseFrame struct {
// contains filtered or unexported fields
}
DownResponseFrame is response metadata sent from the server after starting the RPC, typically before sending data.
func NewDownResponseFrame ¶
func NewDownResponseFrame(shortID ShortID, md []string) DownResponseFrame
func (DownResponseFrame) Metadata ¶
func (t DownResponseFrame) Metadata() []string
func (DownResponseFrame) Type ¶
func (t DownResponseFrame) Type() int
type FinishError ¶
type FinishError struct {
// contains filtered or unexported fields
}
func (FinishError) Error ¶
func (t FinishError) Error() string
func (FinishError) Message ¶
func (t FinishError) Message() string
func (FinishError) Metadata ¶
func (t FinishError) Metadata() []string
func (FinishError) StatusCode ¶
func (t FinishError) StatusCode() int
type Frame ¶
Frame is the basic frame for all rpc protocol related messages.
func FrameFromProto ¶
func FrameFromProto(msg *pb.RPCFrame, memm MemoryManager) Frame
type FrameCallback ¶
type FullID ¶
type FullID struct {
// contains filtered or unexported fields
}
FullID is the full ID for a connection.
func RandomFullID ¶
RandomFullID creates a random FullID.
type HalfCloseError ¶
type HalfCloseError struct { }
func (HalfCloseError) Error ¶
func (t HalfCloseError) Error() string
type Handler ¶
type Handler interface { Identifiable Init(*RPC, FrameReceiver, FrameSender) }
Handler handles one direction of the communication for an RPC. An RPC has 2 Handler, one for upstream (to the server) and one downstream (to the client).
type IBList ¶
type IBList string
first 2 bytes contains number of parts: n then n-1 times 2 bytes indexes of each part after the first after n * 2 bytes the first part
type IDCollision ¶
type IDCollision struct {
ID ShortID
}
func (IDCollision) Error ¶
func (t IDCollision) Error() string
type IDMismatch ¶
type IDMismatch struct {
Frame Frame
}
func (IDMismatch) Error ¶
func (t IDMismatch) Error() string
type Identifiable ¶
type InitFunc ¶
type InitFunc func(*RPC, FrameReceiver, FrameSender)
type LinkHandler ¶
type LinkHandler struct { MultiRPCHandler // contains filtered or unexported fields }
implements Handler
func NewLinkHandler ¶
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
The Manager holds all active RPCs. Its biggest function is that it works as a demultiplexer by dispatching RPCFrames to the RPC they belong to based on the RPC ID. Here one can also register listeners RPC events and track statistics. Unless we go for keepalives and auto cleanup, the manager is not responsible for closing RPCs, this is the job of the module who creates the RPC.
func NewManager ¶
func NewManager() *Manager
func (*Manager) Add ¶
Add registers an RPC at the manager. It must be unstarted, no frames have been sent yet. The RPC is automatically removed after it finishes.
func (*Manager) AddListener ¶
func (t *Manager) AddListener(cb FrameCallback)
type MemoryManager ¶
type MemoryManager interface { // The total memory managed by this instance. Max() int // A snapshot of the memory amount currently acquired, only for debugging purposes and may be slow. Used() int // Reserve some of the memory from the manager. This blocks until enough memory is available. // The returned ticket must be released eventually! Acquire(int) MemoryTicket // Reserve some of the memory from the manager only if enough memory is available, never blocks. // If a ticket is returned, it must be released eventually! AcquireLow(int) MemoryTicket AcquireCtx(context.Context, int) (MemoryTicket, error) // contains filtered or unexported methods }
A MemoryManager helps track and limit memory consumption of certain processes. It guards an amount of memory. To use some of this memory, a ticket must be acquired and released later to free the memory for other users.
func NewCondMemoryManager ¶
func NewCondMemoryManager(max int) MemoryManager
NewCondMemoryManager creates a memory manager that uses a central mutex for all memory interactions.
func NewNoMemoryManager ¶
func NewNoMemoryManager() MemoryManager
type MemoryTicket ¶
type MemoryTicket interface { // Size returns the amount of memory that can be used with this ticket. Size() int // Reduce can be used to lower the ticket size if it turns out that less memory is needed. // Implementations can choose to ignore this or shrink less than requested. ReduceTo(newSize int) // Release to set the ticket size to 0 and free all memory. Release() }
A MemoryTicket allows an amount of memory to be used.
type Metric ¶
type Metric struct {
Hops int
}
Metric describes the quality of a route. It has a comparison function to sort metrics from best to worst routes.
func MetricFromProto ¶
type MultiRPCHandler ¶
type MultiRPCHandler struct { SingleRPCHandler // contains filtered or unexported fields }
MultiRPCHandler is an implementation of Handler that tracks open RPCs and aborts them when the handler is closed.
func NewMultiRPCHandler ¶
func NewMultiRPCHandler(id uint64, infoString string, initRPC InitFunc) *MultiRPCHandler
func NewServerCallHandler ¶
func NewServerCallHandler(identity uint64, infoStr string, ctx context.Context, memm MemoryManager, serverCallHandler func(serverCall *ServerCall)) *MultiRPCHandler
func (*MultiRPCHandler) Close ¶
func (r *MultiRPCHandler) Close()
Close sends a signal to all active RPCs over this route to abort and push a finish frame. NOT THREAD SAFE
func (*MultiRPCHandler) Init ¶
func (r *MultiRPCHandler) Init(rpc *RPC, rcv FrameReceiver, snd FrameSender)
Init implements Handler.Init. NOT THREAD SAFE
type PrefixMapEntry ¶
type PrefixMapEntry struct { Key *Address Value interface{} }
type PrefixTreeMap ¶
type PrefixTreeMap struct {
// contains filtered or unexported fields
}
func (*PrefixTreeMap) Clear ¶
func (ptm *PrefixTreeMap) Clear()
Clear removes all entries from the tree.
func (*PrefixTreeMap) Get ¶
func (ptm *PrefixTreeMap) Get(key *Address) interface{}
func (PrefixTreeMap) GetChildren ¶
func (ptm PrefixTreeMap) GetChildren(key *Address) (children []PrefixMapEntry)
GetChildren returns the direct children of a node, if one exists for the given key. Otherwise returns nil. Values can be nil if the child node has no value directly assigned to it.
func (PrefixTreeMap) GetNearest ¶
func (ptm PrefixTreeMap) GetNearest(key *Address) (depth int, value interface{})
GetNearest returns the entry of the tree with the most matching prefix of the given key and the value associated with it, which can be nil. Returns a length 0 key if no entry with any matching prefix exist.
func (PrefixTreeMap) GetSubtree ¶
func (ptm PrefixTreeMap) GetSubtree(key *Address) (entries []PrefixMapEntry)
GetSubtree returns all keys with values of the subtree including the given key, or nil if the key is not part of the tree.
func (PrefixTreeMap) IterateSubtree ¶
func (ptm PrefixTreeMap) IterateSubtree(key *Address, action func(PrefixMapEntry) bool)
IterateSubtree performs the action on all nodes of the entire subtree, including keys with nil values. Aborts when the action returns false.
func (*PrefixTreeMap) Put ¶
func (ptm *PrefixTreeMap) Put(key *Address, value interface{}) (previousValue interface{})
Put maps the given key to the given value and returns the previously mapped value, which can be nil.
func (*PrefixTreeMap) Remove ¶
func (ptm *PrefixTreeMap) Remove(key *Address) (previousValue interface{})
Remove clears the mapped value of the given key. If the key is parent of another key, its value is set to nil. Returns the previous value, which can be nil.
func (PrefixTreeMap) RemoveSubtree ¶
func (ptm PrefixTreeMap) RemoveSubtree(key *Address) (entries []PrefixMapEntry)
RemoveSubtree removes the subtree including the given key and returns the removed entries, or nil if the key is not part of the tree.
func (*PrefixTreeMap) Size ¶
func (ptm *PrefixTreeMap) Size() int
type Quanda ¶
type Quanda struct {
// contains filtered or unexported fields
}
Quanda is a module handling the query and announce protocol.
func (*Quanda) HandleAnnounce ¶
func (qa *Quanda) HandleAnnounce(announce *AnnounceFrame, handler *LinkHandler)
func (*Quanda) HandleQuery ¶
func (qa *Quanda) HandleQuery(query *QueryFrame, handler *LinkHandler)
func (*Quanda) OpenQueryNames ¶
type QueryFrame ¶
type QueryFrame struct {
// contains filtered or unexported fields
}
func NewQueryFrame ¶
func NewQueryFrame(name *Address, deadline time.Time) *QueryFrame
func NewQueryFrameFromProto ¶
func NewQueryFrameFromProto(m *pb.Query) *QueryFrame
func (*QueryFrame) Deadline ¶
func (f *QueryFrame) Deadline() time.Time
func (*QueryFrame) Name ¶
func (f *QueryFrame) Name() *Address
func (*QueryFrame) Proto ¶
func (f *QueryFrame) Proto() *pb.Query
type RPC ¶
type RPC struct {
// contains filtered or unexported fields
}
RPC is the local handler for an end-to-end bidirectional communication channel. 1. ClientCaller creates RPC 2. ClientCaller has downstream handler, sets it to RPC 3. Someone looks up upstream handler and sets it to RPC 4. Use RPC, send messages, start with Start 5. ClientCaller close the RPC to close the channels
func (*RPC) Abort ¶
Abort stops this RPC externally by sending cancel and finish frames in both directions of the RPC
func (*RPC) Finished ¶
Finished returns true when the call has finished, either due to a server Finished-frame or a client Cancel-frame.
func (*RPC) SetDownstreamHandler ¶
SetDownstreamHandler sets the handler of the client side of the connection, the initiator.
func (*RPC) SetUpstreamHandler ¶
SetUpstreamHandler sets the handler on the server side of the connection, the receiver.
type RPCNotStartedError ¶
type RPCNotStartedError struct { }
func (RPCNotStartedError) Error ¶
func (t RPCNotStartedError) Error() string
type RouteMap ¶
type RouteMap struct {
// contains filtered or unexported fields
}
RouteMap is a bitchy data structure that basically has a bidrectional mapping.
First, the obvious use case, given a destination as a query, it has to return the best route to that destination. So some map lookup structure with addresses as keys and a selection of routes as result, of which we can pick the best. Ergo destToRouteMap which has as value a routeHeap where we can retrieve the shortest route.
Second, routes can be updated and a single route can serve multiple destinations, so we need a lookup map with route ids as key to get a second map with destination as key to get a handle to the routeHeap element to change.
func (*RouteMap) Add ¶
func (rmap *RouteMap) Add(r Identifiable) error
Add puts a route in the list of available routes. Initially no destinations are reachable via this route.
func (*RouteMap) AddListener ¶
func (rmap *RouteMap) AddListener(listener DestinationEventListener)
func (*RouteMap) DestinationOffline ¶
func (rmap *RouteMap) DestinationOffline(dest *Address, r Identifiable)
DestinationOffline removes the route as option for the given destination.
func (*RouteMap) DestinationUpdate ¶
func (rmap *RouteMap) DestinationUpdate(dest *Address, r Identifiable, metric Metric)
DestinationUpdate updates the route for a destination with a changed metric, possibly changing the best route for the destination.
func (*RouteMap) Get ¶
func (rmap *RouteMap) Get(id uint64) Identifiable
func (*RouteMap) GetAll ¶
func (rmap *RouteMap) GetAll() (res []Identifiable)
func (*RouteMap) GetNearest ¶
func (rmap *RouteMap) GetNearest(dest *Address) (int, Identifiable, Metric)
func (*RouteMap) Remove ¶
func (rmap *RouteMap) Remove(r Identifiable) bool
Remove takes the route and all destinations that were reachable via this route offline.
func (*RouteMap) Route ¶
func (rmap *RouteMap) Route(dest *Address) Identifiable
Route returns the best route to the destination, or nil if no route is currently available.
type Router ¶
type Router interface { Route(dest *Address) Identifiable GetNearest(dest *Address) (int, Identifiable, Metric) Add(r Identifiable) error Get(id uint64) Identifiable GetAll() []Identifiable DestinationOffline(dest *Address, r Identifiable) DestinationUpdate(dest *Address, r Identifiable, metric Metric) Remove(h Identifiable) bool AddListener(listener DestinationEventListener) }
type RoutingError ¶
RoutingError is an error issued when an RPC cannot start because no route to its destination could be found.
func (RoutingError) Error ¶
func (e RoutingError) Error() string
type ServerCall ¶
type ServerCall struct { Call // contains filtered or unexported fields }
func (*ServerCall) Finish ¶
func (c *ServerCall) Finish()
func (*ServerCall) FinishExt ¶
func (c *ServerCall) FinishExt(code codes.Code, message string, md []string)
func (*ServerCall) Receive ¶
func (c *ServerCall) Receive() ([]byte, error)
func (*ServerCall) Send ¶
func (c *ServerCall) Send(data []byte) error
type ServerCallFactory ¶
type ServerCallFactory struct {
// contains filtered or unexported fields
}
func (*ServerCallFactory) Init ¶
func (scf *ServerCallFactory) Init(rpc *RPC, rcv FrameReceiver, snd FrameSender)
type ShortID ¶
type ShortID = uint64
ShortID is the part of the ID used in all communication of a connection.
type SingleRPCHandler ¶
type SingleRPCHandler struct {
// contains filtered or unexported fields
}
SingleRPCHandler is an implementation of Handler for a single RPC.
func NewSingleRPCHandler ¶
func NewSingleRPCHandler(id uint64, infoString string, initRPC InitFunc) *SingleRPCHandler
func (*SingleRPCHandler) Init ¶
func (r *SingleRPCHandler) Init(rpc *RPC, rcv FrameReceiver, snd FrameSender)
Init implements Handler.Init. NOT THREAD SAFE
func (*SingleRPCHandler) String ¶
func (r *SingleRPCHandler) String() string
String implements Identifiable.String
type UpCancelFrame ¶
type UpCancelFrame struct {
// contains filtered or unexported fields
}
UpCancelFrame tells upstream the client has abandoned this RPC.
func NewUpCancelFrame ¶
func NewUpCancelFrame(shortID ShortID, message string) UpCancelFrame
func (UpCancelFrame) Message ¶
func (t UpCancelFrame) Message() string
func (UpCancelFrame) Type ¶
func (t UpCancelFrame) Type() int
type UpCloseFrame ¶
type UpCloseFrame struct {
// contains filtered or unexported fields
}
UpCloseFrame indicates upstream that the client is finished sending data.
func NewUpCloseFrame ¶
func NewUpCloseFrame(shortID ShortID) UpCloseFrame
func (UpCloseFrame) Type ¶
func (t UpCloseFrame) Type() int
type UpDataFrame ¶
type UpDataFrame struct {
// contains filtered or unexported fields
}
func NewUpDataFrame ¶
func NewUpDataFrame(shortID ShortID, chunk *Chunk) UpDataFrame
func (UpDataFrame) Chunk ¶
func (t UpDataFrame) Chunk() *Chunk
func (UpDataFrame) Type ¶
func (t UpDataFrame) Type() int
type UpStartFrame ¶
type UpStartFrame struct {
// contains filtered or unexported fields
}
UpStartFrame initiates an RPC and is upstream.
func NewUpStartFrame ¶
func NewUpStartFrame(fullId *FullID, metadata []string, props map[string][]byte) UpStartFrame
func (UpStartFrame) Dest ¶
func (t UpStartFrame) Dest() *Address
func (UpStartFrame) Metadata ¶
func (t UpStartFrame) Metadata() []string
func (UpStartFrame) Properties ¶
func (t UpStartFrame) Properties() map[string][]byte
func (UpStartFrame) Source ¶
func (t UpStartFrame) Source() *Address
func (UpStartFrame) Type ¶
func (t UpStartFrame) Type() int