router

package module
v0.0.0-...-86dda10 Latest Latest
Warning

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

Go to latest
Published: Jan 5, 2024 License: BSD-3-Clause Imports: 16 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BestNode

func BestNode(id string, ordinal uint32, nodes map[uint32]struct{}) uint32

func BestOf

func BestOf(id string, nodes map[uint32]struct{}) uint32

func GRPCSettings

func GRPCSettings() []grpc.ServerOption

func GetLocationArray

func GetLocationArray(id uint64, highestKnownOrdinal uint32) []uint32

returns a list of nodes from 0 to highestKnownOrdinal, randomly but deterministically sorted based on the id the list is stable even with changes to highestKnownOrdinal (in other words, changing highestKnownOrdinal will add/remove entries, but will never reorder them)

func GetLocationArrayString

func GetLocationArrayString(id string, highestKnownOrdinal uint32) []uint32

func MustParseOrdinal

func MustParseOrdinal(ordinalStr string) uint32

Types

type Loader

type Loader interface {
	Load(ctx context.Context, resourceType ResourceType, resourceId string) error
	Unload(resourceType ResourceType, resourceId string)
}

type ResourceType

type ResourceType uint32

type Router

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

func New

func New(server *grpc.Server, ordinal uint32, peerDNSFormat string, loader Loader, readyCallback func(), resourceTypes ...ResourceType) *Router

func (*Router) Locate

func (router *Router) Locate(resourceType ResourceType, resourceId string) (interface{ RUnlock() }, *grpc.ClientConn, bool, error)

Locate returns a processor for the given device, to either handle the request locally, or forward it on to the appropriate peer

func (*Router) LocateWithLoadFunc

func (router *Router) LocateWithLoadFunc(resourceType ResourceType, resourceId string, loadFunc func(ctx context.Context, resourceType ResourceType, deviceId string) error) (interface{ RUnlock() }, *grpc.ClientConn, bool, error)

func (*Router) Stop

func (router *Router) Stop()

func (*Router) UnloadDevice

func (router *Router) UnloadDevice(resourceType ResourceType, key string)

this should be called when a device has been, or should be, unloaded **from the local node only** due to external circumstance (device lock lost, device deleted, inactivity timeout, etc.)

func (*Router) UnloadDeviceWithUnloadFunc

func (router *Router) UnloadDeviceWithUnloadFunc(resourceType ResourceType, resourceId string, unloadFunc func(resourceType ResourceType, resourceId string))

Directories

Path Synopsis
protos

Jump to

Keyboard shortcuts

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