Documentation ¶
Index ¶
- Constants
- Variables
- func CreateMqttClient(protocol, host, port, clientID, username, password string) mqtt.Client
- func Duration(d time.Duration, dicimal int) time.Duration
- func GetBool(env string, def bool) bool
- func NewLoggingTransport(transport http.RoundTripper) *http.Client
- func SetLogLevel()
- func StartPrometheusListener()
- func XID() string
- type ClientOption
- type LoggingTransport
- type RestClient
- func (c *RestClient) DELETE(uri string, request, response interface{}) (int, error)
- func (c *RestClient) GET(uri string, response interface{}) (int, error)
- func (c *RestClient) POST(uri string, request, response interface{}) (int, error)
- func (c *RestClient) PUT(uri string, request, response interface{}) (int, error)
- func (c *RestClient) SetClient(cl *http.Client)
- type ZoneChangeEvent
Constants ¶
View Source
const ( // https://www.hivemq.com/blog/mqtt-essentials-part-6-mqtt-quality-of-service-levels/ AtMostOnce byte = 0 AtLeastOnce byte = 1 ExactlyOnce byte = 2 LOG_LEVEL = "log_level" PROMETHEUS_HOST = "prometheus_host" PROMETHEUS_METRICS_PATH = "prometheus_metrics_path" )
View Source
const ( HttpEndpoint = "HTTP_ENDPOINT" ApiAgent = "apikit/rest" // format error messages MsgStatus = "%s. status: %d" )
Variables ¶
View Source
var ( // ErrApiInvocationError indicates an error in an API call ErrApiInvocationError = errors.New("api invocation error") )
Functions ¶
func CreateMqttClient ¶
func NewLoggingTransport ¶
func NewLoggingTransport(transport http.RoundTripper) *http.Client
func SetLogLevel ¶
func SetLogLevel()
func StartPrometheusListener ¶
func StartPrometheusListener()
Types ¶
type ClientOption ¶
type ClientOption interface {
Apply(ds *settings.DialSettings)
}
func WithCredentials ¶
func WithCredentials(userid, token string) ClientOption
WithCredentials returns a ClientOption that overrides the default credentials used for a service.
func WithEndpoint ¶
func WithEndpoint(url string) ClientOption
WithEndpoint returns a ClientOption that overrides the default endpoint to be used for a service.
type LoggingTransport ¶
type LoggingTransport struct {
InnerTransport http.RoundTripper
}
RestClient - API client encapsulating the http client
type RestClient ¶
type RestClient struct { HttpClient *http.Client Settings *settings.DialSettings Trace string }
RestClient - API client encapsulating the http client
func NewRestClient ¶
func NewRestClient(ctx context.Context, opts ...ClientOption) (*RestClient, error)
func (*RestClient) DELETE ¶
func (c *RestClient) DELETE(uri string, request, response interface{}) (int, error)
func (*RestClient) GET ¶
func (c *RestClient) GET(uri string, response interface{}) (int, error)
GET is used to request data from the API. No payload, only queries!
func (*RestClient) POST ¶
func (c *RestClient) POST(uri string, request, response interface{}) (int, error)
func (*RestClient) PUT ¶
func (c *RestClient) PUT(uri string, request, response interface{}) (int, error)
func (*RestClient) SetClient ¶
func (c *RestClient) SetClient(cl *http.Client)
type ZoneChangeEvent ¶
type ZoneChangeEvent struct { PreviousZoneID string `json:"previousZoneId,omitempty"` NextZoneID string `json:"nextZoneId,omitempty"` CarID string `json:"carId,omitempty"` VIN string `json:"vin,omitempty"` }
{"previousZoneId":"zone-north","nextZoneId":null,"carId":"test-car1","vin":null}
func (*ZoneChangeEvent) String ¶
func (evt *ZoneChangeEvent) String() string
Click to show internal directories.
Click to hide internal directories.