Documentation ¶
Overview ¶
Package atcclient implements a client for the Roxy Air Traffic Control protocol.
Index ¶
- Constants
- func AddLoad(value float32)
- func DefaultDefaultLoadFunc() float32
- func SubLoad(value float32)
- type ATCClient
- func (c *ATCClient) ClientAssign(ctx context.Context, req *roxypb.ClientAssignRequest) (context.CancelFunc, <-chan []*roxypb.Event, <-chan error, error)
- func (c *ATCClient) Close() error
- func (c *ATCClient) Dial(ctx context.Context, addr *net.TCPAddr) (*grpc.ClientConn, roxypb.AirTrafficControlClient, error)
- func (c *ATCClient) Find(ctx context.Context, serviceName string, shardID uint32, useCache bool) (*net.TCPAddr, error)
- func (c *ATCClient) Lookup(ctx context.Context, serviceName string) (*roxypb.LookupResponse, error)
- func (c *ATCClient) ServerAnnounce(ctx context.Context, req *roxypb.ServerAnnounceRequest, loadFn LoadFunc) (context.CancelFunc, <-chan error, error)
- type LoadFunc
Constants ¶
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.
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 ¶
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) Dial ¶
func (c *ATCClient) Dial(ctx context.Context, addr *net.TCPAddr) (*grpc.ClientConn, roxypb.AirTrafficControlClient, error)
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) 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.