atcclient

package
v0.4.3 Latest Latest
Warning

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

Go to latest
Published: May 13, 2021 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Overview

Package atcclient implements a client for the Roxy Air Traffic Control protocol.

Index

Constants

View Source
const LoadInterval = 10 * time.Second

LoadInterval is the time interval between load reports sent within ServerAnnounce.

Variables

This section is empty.

Functions

func AddLoad

func AddLoad(value float32)

AddLoad adds the given value to the current load. Only affects the value returned by DefaultDefaultLoadFunc.

func DefaultDefaultLoadFunc added in v0.4.3

func DefaultDefaultLoadFunc() float32

DefaultDefaultLoadFunc is the default value for DefaultLoadFunc.

func SubLoad

func SubLoad(value float32)

SubLoad subtracts the given value from the current load. Only affects the value returned by DefaultDefaultLoadFunc.

Types

type ATCClient

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

ATCClient is a client for communicating with the Roxy Air Traffic Controller service.

Each ATC tower is responsible for a set of (ServiceName, ShardID) tuples, which are exclusive to that tower. The client automatically determines which tower it needs to speak with, by asking any tower within the service to provide instructions.

func New

func New(cc *grpc.ClientConn, tlsConfig *tls.Config) (*ATCClient, error)

New constructs and returns a new ATCClient. The cc argument is a gRPC ClientConn configured to speak to any/all ATC towers. The tlsConfig argument specifies the TLS client configuration to use when speaking to individual ATC towers, or nil for gRPC with no TLS.

func (*ATCClient) ClientAssign

func (c *ATCClient) ClientAssign(ctx context.Context, req *roxypb.ClientAssignRequest) (context.CancelFunc, <-chan []*roxypb.Event, <-chan error, error)

ClientAssign starts a subscription for assignment Events. If the method returns with no error, then the caller must call the returned CancelFunc when it is no longer interested in receiving Events, and the caller is also responsible for draining both channels in a timely manner.

func (*ATCClient) Close

func (c *ATCClient) Close() error

Close closes all gRPC channels and blocks until all resources are freed.

func (*ATCClient) Dial

Dial returns a gRPC ClientConn connected directly to the given ATC tower.

The caller should _not_ call Close() on it. It is owned by the ATCClient and will be re-used until the ATCClient itself is Close()'d.

func (*ATCClient) Find

func (c *ATCClient) Find(ctx context.Context, serviceName string, shardID uint32, useCache bool) (*net.TCPAddr, error)

Find queries any ATC tower for information about which ATC tower is responsible for the given (ServiceName, ShardID) tuple. If useCache is false, then the local cache will not be consulted.

func (*ATCClient) Lookup

func (c *ATCClient) Lookup(ctx context.Context, serviceName string) (*roxypb.LookupResponse, error)

Lookup queries any ATC tower for information about the given service.

func (*ATCClient) ServerAnnounce

func (c *ATCClient) ServerAnnounce(ctx context.Context, req *roxypb.ServerAnnounceRequest, loadFn LoadFunc) (context.CancelFunc, <-chan error, error)

ServerAnnounce starts announcing that a new server is available for the given (ServiceName, ShardID) tuple. If the method returns with no error, then the caller must call the returned CancelFunc when the announcement should be withdrawn, and the caller must also ensure that the returned error channel is drained in a timely manner. The error channel will be closed once all goroutines and other internal resources have been released.

type LoadFunc

type LoadFunc func() float32

LoadFunc is a function that returns the current load each time it is called. It must be thread-safe.

var DefaultLoadFunc LoadFunc = DefaultDefaultLoadFunc

DefaultLoadFunc is the default implementation of LoadFunc.

Jump to

Keyboard shortcuts

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