Documentation ¶
Overview ¶
Package portdiscovery hosts common code shared by CFT containerized services. It provides APIs to write service port number to a metadata file within the container that allows clients (e.g. cros-tool-runner) to look up the info. More info at go/cft-port-discovery
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Api ¶
type Api interface { // WriteMetadata writes metadata to a file based on Metadata. WriteMetadata(Metadata) error // GetPortFromAddress returns the port number of the given the address. The // address should be in the format of ".*:port". GetPortFromAddress(string) (string, error) }
Api is the interface of the portdiscovery utility.
type Metadata ¶
type Metadata struct { Port string // Mandatory Name string // Optional Version string // Optional }
Metadata represents the data to be written into the metadata file. The data will be translated into standardized key value pair and written into the file following the format of an env file. All values are in string format and will be wrapped with single quotes during the conversion. The metadata file is kept at a minimum level for port discovery only as more complicated and structured data could/should be surfaced through service end points. Future extensions may consider adding a Config object to control the behavior and a map of free formed key-value pair per container (not recommended unless absolutely necessary).
type PortDiscovery ¶
PortDiscovery is an implementation of Api.
func (*PortDiscovery) GetPortFromAddress ¶
func (p *PortDiscovery) GetPortFromAddress(address string) (string, error)
func (*PortDiscovery) WriteMetadata ¶
func (p *PortDiscovery) WriteMetadata(metadata Metadata) error