internal

package
v0.0.0-...-246bbf3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 26, 2024 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

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 CreateMqttClient(protocol, host, port, clientID, username, password string) mqtt.Client

func Duration

func Duration(d time.Duration, dicimal int) time.Duration

func GetBool

func GetBool(env string, def bool) bool

FIXME move this to stdlib

func NewLoggingTransport

func NewLoggingTransport(transport http.RoundTripper) *http.Client

func SetLogLevel

func SetLogLevel()

func StartPrometheusListener

func StartPrometheusListener()

func XID

func XID() string

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

func (*LoggingTransport) RoundTrip

func (t *LoggingTransport) RoundTrip(req *http.Request) (*http.Response, error)

RoundTrip logs the request and reply if the log level is debug or trace

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

Directories

Path Synopsis
Most of the code is lifted from https://github.com/googleapis/google-api-go-client/blob/main/internal/settings.go
Most of the code is lifted from https://github.com/googleapis/google-api-go-client/blob/main/internal/settings.go

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL