Documentation ¶
Index ¶
- Constants
- Variables
- func NewLCAHandler(bootstraps []multiaddr.Multiaddr, sPsk string) func(network.Stream)
- func RequestHandler(address string) func(network.Stream)
- type LCAAllocator
- type LCAManager
- func (lca *LCAManager) AllocBetterService(serviceHash string, perf p2putil.PerfInd) (peer.ID, p2putil.PerfInd, error)
- func (lca *LCAManager) AllocService(serviceHash string) (peer.ID, p2putil.PerfInd, error)
- func (lca *LCAManager) FindService(serviceHash string) (peer.ID, p2putil.PerfInd, error)
- func (lca *LCAManager) Request(pid peer.ID, req *http.Request) (*http.Response, error)
Constants ¶
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
const (
LCAAPCmdStartProgram = "start-program"
)
Commands
Variables ¶
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 ¶
Generator function for LCA handler function Used to allow the handler to remember the bootstraps and PSK
func RequestHandler ¶
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 ¶
Alias for p2pnode.Node for type safety
func NewLCAAllocator ¶
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 ¶
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 ¶
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