Documentation ¶
Overview ¶
Package ingestsvc contains source code for Ingest service that allows to read port resources from input JSON file and store them in Ports service.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { // PortsFilePath is a path to the JSON file containing input ports. Env var: PORTS_FILE_PATH. Required. PortsFilePath string `env:"PORTS_FILE_PATH,notEmpty"` // PortsServiceAddress is a TCP address of the Ports service. Env var: PORTS_SVC_ADDRESS. Default: ":9090". PortsServiceAddress string `env:"PORTS_SVC_ADDRESS" envDefault:":9090"` }
Config is a config for Ingest service.
type Port ¶
type Port struct { Name string `json:"name"` City string `json:"city"` Country string `json:"country"` Alias []string `json:"alias"` Regions []string `json:"regions"` Coordinates []float64 `json:"coordinates"` Province string `json:"province"` Timezone string `json:"timezone"` Unlocs []string `json:"unlocs"` Code string `json:"code"` }
Port models a JSON representation of the port.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service is an Ingest service.
func NewService ¶
NewService creates new Ingest service with given configuration.
func (Service) Run ¶
Run reads all port resources from specified in input JSON file and transmits them to Ports service via gRPC.
The example JSON file with a format expected by the service is located in ./testdata/ports.json. Resources are read from the file one-by-one with a stream to reduce memory consumption and support large files. Run can be stopped by context cancel/timeout. This function is meant to be called only once, because it closes Ports client connection.