master

package
v0.0.0-...-15b4445 Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2022 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Package master holds the code for a master in the robot system. The master is the main coordination point, all other service are discovered through the master. It's main job is to manage and control the set of satellites. A satellite is a server that offers any of the other robot services.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Serve

func Serve(ctx context.Context, grpcServer *grpc.Server, m Master) error

Serve wraps a Master in a grpc server.

Types

type Client

type Client struct {
	// Master is the master this client is talking to.
	// This should not be modifed, the results are undefined if you do.
	Master Master
	// contains filtered or unexported fields
}

Client is a wrapper over a Master object that provides client targeted features.

func NewClient

func NewClient(ctx context.Context, m Master) *Client

NewClient returns a new master client object that talks to the provided Master.

func (*Client) Kill

func (c *Client) Kill(ctx context.Context, to ...string) error

Kill causes an immediate shutdown of the server.

func (*Client) Orbit

func (c *Client) Orbit(ctx context.Context, services ServiceList) (Shutdown, error)

Orbit registers a satellite with the master. The function will only return when the connection is lost.

func (*Client) Restart

func (c *Client) Restart(ctx context.Context, to ...string) error

Restart causes a graceful shutdown and restart of the server.

func (*Client) Search

func (c *Client) Search(ctx context.Context, query *search.Query, handler SatelliteHandler) error

Search delivers the set of satellites that match the query to the supplied function.

func (*Client) Shutdown

func (c *Client) Shutdown(ctx context.Context, to ...string) error

Shutdown causes a graceful shutdown of the server.

type CommandHandler

type CommandHandler func(context.Context, *Command) error

type Master

type Master interface {
	// Search returns a iterator of matching satellites from the store.
	Search(context.Context, *search.Query, SatelliteHandler) error
	// Orbit adds a satellite to the set being managed by the master.
	// The master will use the returned command stream to control the satellite.
	Orbit(context.Context, ServiceList, CommandHandler) error
	// Shutdown is called to ask the master to send shutdown requests to satellites.
	Shutdown(context.Context, *ShutdownRequest) (*ShutdownResponse, error)
}

Master is the interface to a master implementation. It abstracts away whether the master is remote or local.

func NewLocal

func NewLocal(ctx context.Context) Master

NewLocal creates a new local Master that manages it's own satellites.

func NewRemoteMaster

func NewRemoteMaster(ctx context.Context, conn *grpc.ClientConn) Master

NewRemoteMaster returns a Master that talks to a remote grpc Master service.

type SatelliteHandler

type SatelliteHandler func(context.Context, *Satellite) error

Jump to

Keyboard shortcuts

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