Documentation ¶
Index ¶
- func Run(main MainCallback, onTerminate TerminationCallback)
- type Configuration
- type Input
- type MainCallback
- type Output
- type Service
- type ServiceConfiguration
- func (c *ServiceConfiguration) GetFloat(name string) (float64, error)
- func (c *ServiceConfiguration) GetFloatSafe(name string) (float64, error)
- func (c *ServiceConfiguration) GetInt(name string) (int, error)
- func (c *ServiceConfiguration) GetIntSafe(name string) (int, error)
- func (c *ServiceConfiguration) GetString(name string) (string, error)
- func (c *ServiceConfiguration) GetStringSafe(name string) (string, error)
- type ServiceStream
- type Stream
- type TerminationCallback
- type Tuning
- type Type
- type Value
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Run ¶
func Run(main MainCallback, onTerminate TerminationCallback)
Start the program (main) and handle termination
Types ¶
type Configuration ¶
type Configuration struct { // Unique name of this configuration option Name *string `json:"name,omitempty"` // Whether or not this value can be tuned (ota) Tunable *bool `json:"tunable,omitempty"` // The type of this configuration option Type *Type `json:"type,omitempty"` // The value of this configuration option, which can be a string, integer, or float Value *Value `json:"value"` }
type MainCallback ¶
type MainCallback func( s Service, config *ServiceConfiguration, ) error
The user main function to run
type Service ¶
type Service struct { Configuration []Configuration `json:"configuration"` // The resolved input dependencies Inputs []Input `json:"inputs"` // The name of the service (only lowercase letters and hyphens) Name *string `json:"name,omitempty"` Outputs []Output `json:"outputs"` Tuning Tuning `json:"tuning"` // The specific version of the service Version *string `json:"version,omitempty"` Service interface{} `json:"service"` }
The object that injected into a rover process by roverd and then parsed by roverlib to be made available for the user process
func UnmarshalService ¶
func (*Service) GetReadStream ¶
func (s *Service) GetReadStream(service string, name string) *ServiceStream
Get a stream that you can read from (i.e. an input stream). This function panics if the stream does not exist, because fetching a non-existent stream should always terminate to avoid undefined behavior.
func (*Service) GetWriteStream ¶
func (s *Service) GetWriteStream(name string) *ServiceStream
Get a stream that you can write to (i.e. an output stream). This function panics if the stream does not exist, because fetching a non-existent stream should always terminate to avoid undefined behavior.
type ServiceConfiguration ¶
type ServiceConfiguration struct {
// contains filtered or unexported fields
}
func NewServiceConfiguration ¶
func NewServiceConfiguration(service Service) *ServiceConfiguration
func (*ServiceConfiguration) GetFloat ¶
func (c *ServiceConfiguration) GetFloat(name string) (float64, error)
Returns the float value of the configuration option with the given name, returns an error if the option does not exist or does not exist for this type Reading is NOT thread-safe, but we accept the risks because we assume that the user program will read the configuration values repeatedly If you want to read the configuration values concurrently, you should use the GetFloatSafe method
func (*ServiceConfiguration) GetFloatSafe ¶
func (c *ServiceConfiguration) GetFloatSafe(name string) (float64, error)
func (*ServiceConfiguration) GetInt ¶
func (c *ServiceConfiguration) GetInt(name string) (int, error)
Returns the integer value of the configuration option with the given name, returns an error if the option does not exist or does not exist for this type Reading is NOT thread-safe, but we accept the risks because we assume that the user program will read the configuration values repeatedly If you want to read the configuration values concurrently, you should use the GetIntSafe method
func (*ServiceConfiguration) GetIntSafe ¶
func (c *ServiceConfiguration) GetIntSafe(name string) (int, error)
func (*ServiceConfiguration) GetString ¶
func (c *ServiceConfiguration) GetString(name string) (string, error)
Returns the string value of the configuration option with the given name, returns an error if the option does not exist or does not exist for this type Reading is NOT thread-safe, but we accept the risks because we assume that the user program will read the configuration values repeatedly If you want to read the configuration values concurrently, you should use the GetStringSafe method
func (*ServiceConfiguration) GetStringSafe ¶
func (c *ServiceConfiguration) GetStringSafe(name string) (string, error)
type ServiceStream ¶
type ServiceStream struct {
// contains filtered or unexported fields
}
func (*ServiceStream) Read ¶
func (s *ServiceStream) Read() (*rovercom.SensorOutput, error)
Read a rovercom sensor output message from the stream (you will need to switch on the returned message type to cast it to the correct type)
func (*ServiceStream) ReadBytes ¶
func (s *ServiceStream) ReadBytes() ([]byte, error)
Read byte data from the stream
func (*ServiceStream) Write ¶
func (s *ServiceStream) Write(output *rovercom.SensorOutput) error
Write a rovercom sensor output message to the stream
func (*ServiceStream) WriteBytes ¶
func (s *ServiceStream) WriteBytes(data []byte) error
Write byte data to the stream
type TerminationCallback ¶
The function to call when the service is terminated or interrupted
type Value ¶
The value of this configuration option, which can be a string, integer, or float