lca

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Aug 10, 2020 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LCASErrWriteFail    = "Error: writing to buffer"
	LCASErrReadFail     = "Error: reading from buffer"
	LCAPErrUnrecognized = "Error: unrecognized command"
	LCAPErrAllocFail    = "Error: allocation failed"
	LCAPErrDeadProgram  = "Error: program non-responsive"
)

Errors

View Source
const (
	LCAAPCmdStartProgram = "start-program"
)

Commands

Variables

View Source
var (
	DefaultListenAddrs []multiaddr.Multiaddr

	LCAManagerFindProtID    protocol.ID // Deprecated, re-use for something else?
	LCAManagerRequestProtID protocol.ID

	LCAAllocatorProtocolID protocol.ID
	LCAAllocatorRendezvous string
)

Useful defaults

Functions

func NewLCAHandler

func NewLCAHandler(bootstraps []multiaddr.Multiaddr,
	sPsk string) func(network.Stream)

Generator function for LCA handler function Used to allow the handler to remember the bootstraps and PSK

func RequestHandler

func RequestHandler(address string) func(network.Stream)

TODO: Finish this function LCAManagerHandler generator function Used to allow the Handler to remember the service address Generated LCAManagerHandler pings the service it is responsible for to check that it is still up then sends the service address back to the requester.

Types

type LCAAllocator

type LCAAllocator struct {
	Host p2pnode.Node
}

Alias for p2pnode.Node for type safety

func NewLCAAllocator

func NewLCAAllocator(ctx context.Context,
	cfg p2pnode.Config, sPsk string) (LCAAllocator, error)

Constructor for LCA Allocator Input Params:

ctx: Context to pass to the new P2P node
cfg: Configuration settings for the new P2P node
sPsk: Un-hashed PSK passphrase to pass to spawned proxies

type LCAManager

type LCAManager struct {
	// Libp2p node instance for this node
	Host p2pnode.Node
	// Identifier hash for the service this node is responsible for
	P2PHash string
}

for p2pnode.Node and also related

func NewLCAManager

func NewLCAManager(ctx context.Context, cfg p2pnode.Config,
	serviceName string, serviceAddress string) (LCAManager, error)

Constructor for LCA Manager instance If serviceName is empty string start instance in "anonymous mode"

func (*LCAManager) AllocBetterService

func (lca *LCAManager) AllocBetterService(
	serviceHash string, perf p2putil.PerfInd,
) (
	peer.ID, p2putil.PerfInd, error,
)

Requests allocation on LCA Allocators with performance better than "perf"

func (*LCAManager) AllocService

func (lca *LCAManager) AllocService(serviceHash string) (peer.ID, p2putil.PerfInd, error)

Requests allocation on LCA Allocators with good network performance Returns:

  • The peer ID of the allocator that spawned the new instance
  • The performance of the allocator that spawned the instance
  • Any errors.

func (*LCAManager) FindService

func (lca *LCAManager) FindService(serviceHash string) (peer.ID, p2putil.PerfInd, error)

TODO: Move this outside of LCAManager to a more general structure or library?

It's not relevant to controlling the lifecycle of virtual resources.

Finds the best service instance by pinging other LCA Manager instances Returns:

  • ID of candidate peer
  • Latency to candidate peer
  • Any errors

func (*LCAManager) Request

func (lca *LCAManager) Request(pid peer.ID, req *http.Request) (*http.Response, error)

TODO: Move this outside of LCAManager to a more general structure or library?

It's not relevant to controlling the lifecycle of virtual resources.

Jump to

Keyboard shortcuts

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