controls

package
v0.0.0-...-06e0152 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2020 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var NewPipe = func(c PipeClient, appID string) (string, xfer.Pipe, error) {
	return newPipe(xfer.NewPipe(), c, appID)
}

NewPipe creates a new pipe and connects it to the app.

Functions

func NewPipeFromEnds

func NewPipeFromEnds(local, remote io.ReadWriter, c PipeClient, appID string) (string, xfer.Pipe, error)

NewPipeFromEnds creates a new pipe from its ends and connects it to the app.

Types

type DummyPipeClient

type DummyPipeClient struct{}

DummyPipeClient implements PipeClient when running the probe in debugging mode

func (DummyPipeClient) PipeClose

func (DummyPipeClient) PipeClose(appID, pipeID string) error

PipeClose implements controls.PipeClient

func (DummyPipeClient) PipeConnection

func (DummyPipeClient) PipeConnection(appID, pipeID string, pipe xfer.Pipe) error

PipeConnection implements controls.PipeClient

type HandlerRegistry

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

HandlerRegistry uses backend for storing and retrieving control requests handlers.

func NewDefaultHandlerRegistry

func NewDefaultHandlerRegistry() *HandlerRegistry

NewDefaultHandlerRegistry creates a registry with a default backend.

func NewHandlerRegistry

func NewHandlerRegistry(backend HandlerRegistryBackend) *HandlerRegistry

NewHandlerRegistry creates a registry with a custom backend.

func (*HandlerRegistry) Batch

func (r *HandlerRegistry) Batch(toRemove []string, toAdd map[string]xfer.ControlHandlerFunc)

Batch first deletes handlers for given names in toRemove then registers new handlers for given names in toAdd.

func (*HandlerRegistry) HandleControlRequest

func (r *HandlerRegistry) HandleControlRequest(req xfer.Request) xfer.Response

HandleControlRequest performs a control request.

func (*HandlerRegistry) Register

func (r *HandlerRegistry) Register(control string, f xfer.ControlHandlerFunc)

Register registers a new control handler under a given name.

func (*HandlerRegistry) Rm

func (r *HandlerRegistry) Rm(control string)

Rm deletes the handler for a given name.

type HandlerRegistryBackend

type HandlerRegistryBackend interface {
	// Lock locks the backend, so the batch insertions or
	// removals can be performed.
	Lock()
	// Unlock unlocks the registry.
	Unlock()
	// Register a new control handler under a given
	// id. Implementations should not call Lock() or Unlock()
	// here, it will be done by HandlerRegistry.
	Register(control string, f xfer.ControlHandlerFunc)
	// Rm deletes the handler for a given name. Implementations
	// should not call Lock() or Unlock() here, it will be done by
	// HandlerRegistry.
	Rm(control string)
	// Handler gets the handler for a control. Implementations
	// should not call Lock() or Unlock() here, it will be done by
	// HandlerRegistry.
	Handler(control string) (xfer.ControlHandlerFunc, bool)
}

HandlerRegistryBackend is an interface for storing control request handlers.

func NewDefaultHandlerRegistryBackend

func NewDefaultHandlerRegistryBackend() HandlerRegistryBackend

NewDefaultHandlerRegistryBackend creates a default backend for handler registry.

type PipeClient

type PipeClient interface {
	PipeConnection(string, string, xfer.Pipe) error
	PipeClose(string, string) error
}

PipeClient is the type of the thing the probe uses to make pipe connections.

Jump to

Keyboard shortcuts

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