service

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2020 License: Apache-2.0 Imports: 34 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetClientID

func GetClientID(ws *websocket.Conn) string

func IsMappedTo

func IsMappedTo(err error, code int) bool

func NewHTTP

func NewHTTP(requestHandler *RequestHandler, authInterceptor kitHttp.Interceptor) *http.Server

NewHTTP returns HTTP server

func NewSubscriptionSession

func NewSubscriptionSession(ws *websocket.Conn) subscribeSession

func ToDevicesObservationEvent

func ToDevicesObservationEvent(e client.DevicesObservationEvent_type) string

Types

type Config

type Config struct {
	Address                  string             `envconfig:"ADDRESS"`
	Listen                   certManager.Config `envconfig:"LISTEN"`
	Dial                     certManager.Config `envconfig:"DIAL"`
	JwksURL                  string             `envconfig:"JWKS_URL"`
	ResourceDirectoryAddr    string             `envconfig:"RESOURCE_DIRECTORY_ADDRESS"`
	CertificateAuthorityAddr string             `envconfig:"CERTIFICATE_AUTHORITY_ADDRESS"`
	WebSocketReadLimit       int64              `envconfig:"WEBSOCKET_READ_LIMIT"`
	WebSocketReadTimeout     time.Duration      `envconfig:"WEBSOCKET_READ_TIMEOUT"`
}

Config represent application configuration

func (Config) String

func (c Config) String() string

type Device

type Device struct {
	Device schema.Device `json:"device"`
	Status Status        `json:"status"`
}

type DeviceEvent

type DeviceEvent struct {
	DeviceIDs []string `json:"deviceIds"`
	Status    string   `json:"status"`
}

type DeviceResourceObservationEvent

type DeviceResourceObservationEvent struct {
	Resources []schema.ResourceLink `json:"resources"`
	Event     string                `json:"event"`
}

type ObservationManager

type ObservationManager struct {
	// contains filtered or unexported fields
}

func NewObservationManager

func NewObservationManager() (*ObservationManager, error)

type ObservationResolver

type ObservationResolver interface {
	StartObservation(r *http.Request, ws *websocket.Conn, accessToken string) (SubscribeSession, error)
	StopObservation(subscriptionID string) error
}

type RequestHandler

type RequestHandler struct {
	// contains filtered or unexported fields
}

RequestHandler for handling incoming request

func NewRequestHandler

func NewRequestHandler(client *client.Client, caClient pbCA.CertificateAuthorityClient, config *Config, manager *ObservationManager) *RequestHandler

NewRequestHandler factory for new RequestHandler

func (*RequestHandler) ServeWs

func (requestHandler *RequestHandler) ServeWs(w http.ResponseWriter, r *http.Request, ob ObservationResolver) error

type RetrieveDeviceWithLinksResponse

type RetrieveDeviceWithLinksResponse struct {
	Device
	Links []schema.ResourceLink `json:"links"`
}

type Server

type Server struct {
	// contains filtered or unexported fields
}

Server handle HTTP request

func New

func New(cfg Config) (*Server, error)

New parses configuration and creates new Server with provided store and bus

func (*Server) Serve

func (s *Server) Serve() error

Serve starts the service's HTTP server and blocks

func (*Server) Shutdown

func (s *Server) Shutdown() error

Shutdown ends serving

type Status

type Status string
const Status_OFFLINE Status = "offline"
const Status_ONLINE Status = "online"

type SubscribeSession

type SubscribeSession interface {
	ClientId() string
	SubscriptionId() string
	SetSubscriptionId(id string)
	Write(data interface{})
	ReadLoop(rh *RequestHandler, ob ObservationResolver)
	WriteLoop()
	OnClose()
}

type TokenMessage added in v1.1.0

type TokenMessage struct {
	Token string `json:"token"`
}

Jump to

Keyboard shortcuts

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