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, MIT Imports: 43 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddHandler

func AddHandler(svr *kitNetGrpc.Server, config HandlerConfig, clientTLS *tls.Config) error

func NewDeviceSubscription

func NewDeviceSubscription(id, userID string, send SendEventFunc, resourceProjection *Projection, deviceEvent *pb.SubscribeForEvents_DeviceEventFilter) *deviceSubscription

func NewDevicesSubscription

func NewDevicesSubscription(id, userID string, send SendEventFunc, resourceProjection *Projection, devicesEvent *pb.SubscribeForEvents_DevicesEventFilter) *devicesSubscription

func NewResourceCtx

func NewResourceCtx(subscriptions *subscriptions, updateNotificationContainer *notification.UpdateNotificationContainer, retrieveNotificationContainer *notification.RetrieveNotificationContainer, deleteNotificationContainer *notification.DeleteNotificationContainer) func(context.Context) (eventstore.Model, error)

func NewResourceSubscription

func NewResourceSubscription(id, userID string, send SendEventFunc, resourceProjection *Projection, resourceEvent *pb.SubscribeForEvents_ResourceEventFilter) *resourceSubscription

func NewSubscription

func NewSubscription(userID, id string, send SendEventFunc, resourceProjection *Projection) *subscription

func NewSubscriptions

func NewSubscriptions() *subscriptions

func Register

func Register(server *grpc.Server, handler *RequestHandler)

Register registers the handler instance with a gRPC server.

Types

type ClientCfg

type ClientCfg struct {
	pb.ClientConfigurationResponse
	CloudCAPool string `envconfig:"CLOUD_CA_POOL" env:"CLOUD_CA_POOL" long:"cloud-ca" description:"file path to the root certificate in PEM format"`
}

type Config

type Config struct {
	OAuth                     manager.Config `envconfig:"OAUTH"`
	AuthServerAddr            string         `envconfig:"AUTH_SERVER_ADDRESS" default:"127.0.0.1:9100"`
	ResourceAggregateAddr     string         `envconfig:"RESOURCE_AGGREGATE_ADDRESS"  default:"127.0.0.1:9100"`
	FQDN                      string         `envconfig:"FQDN" default:"grpcgw.ocf.cloud"`
	TimeoutForRequests        time.Duration  `envconfig:"TIMEOUT_FOR_REQUESTS"  default:"10s"`
	ClientConfiguration       ClientCfg      `envconfig:"CLIENT_CONFIGURATION"`
	ProjectionCacheExpiration time.Duration  `envconfig:"PROJECTION_CACHE_EXPIRATION" default:"1m"`
}

Config represent application configuration

func (Config) String

func (c Config) String() string

String return string representation of Config

type Device

type Device struct {
	ID       string
	Resource *schema.Device
	IsOnline bool
	// contains filtered or unexported fields
}

func (Device) ToProto

func (d Device) ToProto() *pb.Device

type DeviceDirectory

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

func NewDeviceDirectory

func NewDeviceDirectory(projection *Projection, deviceIds []string) *DeviceDirectory

NewDeviceDirectory creates new device directory.

func (*DeviceDirectory) GetDevices

func (dd *DeviceDirectory) GetDevices(req *pb.GetDevicesRequest, srv pb.GrpcGateway_GetDevicesServer) (err error)

GetDevices provides list state of devices.

type DeviceIDVersion

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

type HandlerConfig

type HandlerConfig struct {
	Mongo   mongodb.Config
	Nats    nats.Config
	Service Config

	GoRoutinePoolSize               int           `envconfig:"GOROUTINE_POOL_SIZE" default:"16"`
	UserDevicesManagerTickFrequency time.Duration `envconfig:"USER_MGMT_TICK_FREQUENCY" default:"15s"`
	UserDevicesManagerExpiration    time.Duration `envconfig:"USER_MGMT_EXPIRATION" default:"1m"`
}

type Projection

type Projection struct {
	*projectionRA.Projection
	// contains filtered or unexported fields
}

func NewProjection

func NewProjection(ctx context.Context, name string, store eventstore.EventStore, subscriber eventbus.Subscriber, newModelFunc eventstore.FactoryModelFunc, expiration time.Duration) (*Projection, error)

func (*Projection) GetResourceCtxs

func (p *Projection) GetResourceCtxs(ctx context.Context, resourceIDsFilter []*pb.ResourceId, typeFilter, deviceIDs strings.Set) (map[string]map[string]*resourceCtx, error)

type RequestHandler

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

RequestHandler handles incoming requests.

func NewRequestHandler

func NewRequestHandler(
	authServiceClient pbAS.AuthorizationServiceClient,
	resourceAggregateClient pbRA.ResourceAggregateClient,
	resourceProjection *Projection,
	subscriptions *subscriptions,
	updateNotificationContainer *notification.UpdateNotificationContainer,
	retrieveNotificationContainer *notification.RetrieveNotificationContainer,
	deleteNotificationContainer *notification.DeleteNotificationContainer,
	timeoutForRequests time.Duration,
	closeFunc func(),
	clientConfiguration pb.ClientConfigurationResponse,
	userDevicesManager *clientAS.UserDevicesManager,
	fqdn string,
) *RequestHandler

NewRequestHandler factory for new RequestHandler.

func NewRequestHandlerFromConfig

func NewRequestHandlerFromConfig(config HandlerConfig, clientTLS *tls.Config) (*RequestHandler, error)

func (*RequestHandler) Close

func (r *RequestHandler) Close()

func (*RequestHandler) DeleteResource added in v1.1.0

func (*RequestHandler) GetClientTLSConfig

func (r *RequestHandler) GetClientTLSConfig() *tls.Config

func (*RequestHandler) GetDevices

func (*RequestHandler) SubscribeForEvents

func (r *RequestHandler) SubscribeForEvents(srv pb.GrpcGateway_SubscribeForEventsServer) error

func (*RequestHandler) UpdateResourcesValues

type ResourceDirectory

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

func New

func New(projection *Projection, deviceIds []string) *ResourceDirectory
type ResourceLink struct {
	// contains filtered or unexported fields
}

type ResourceShadow

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

func NewResourceShadow

func NewResourceShadow(projection *Projection, deviceIds []string) *ResourceShadow

type SendEventFunc

type SendEventFunc func(senderCtx context.Context, e pb.Event) error

type Subscriber

type Subscriber interface {
	UserID() string
	ID() string
	Init(ctx context.Context, currentDevices map[string]bool) error
	Close(reason error) error
}

Jump to

Keyboard shortcuts

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