service

package
v0.0.0-...-ec2f75e Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2020 License: Apache-2.0 Imports: 42 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 GrpcResourceID2ResourceID

func GrpcResourceID2ResourceID(resourceId *pb.ResourceId) string

func NewDeviceSubscription

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

func NewDevicesSubscription

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

func NewResourceCtx

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

func NewResourceSubscription

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

func NewSubscription

func NewSubscription(userID, id string, send SendEventFunc, resourceProjection *projectionRA.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 Config

type Config struct {
	grpc.Config
	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"`
	ResourceDirectoryAddr string         `envconfig:"RESOURCE_DIRECTORY_ADDRESS"  default:"127.0.0.1:9100"`
	FQDN                  string         `envconfig:"FQDN" default:"grpcgw.ocf.cloud"`
	TimeoutForRequests    time.Duration  `envconfig:"TIMEOUT_FOR_REQUESTS"  default:"10s"`
}

Config represent application configuration

func (Config) String

func (c Config) String() string

String return string representation of Config

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 RequestHandler

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

RequestHandler handles incoming requests.

func NewRequestHandler

func NewRequestHandler(
	authServiceClient pbAS.AuthorizationServiceClient,
	deviceDirectoryClient pbDD.DeviceDirectoryClient,
	resourceDirectoryClient pbRD.ResourceDirectoryClient,
	resourceShadowClient pbRS.ResourceShadowClient,
	resourceAggregateClient pbRA.ResourceAggregateClient,
	resourceProjection *projectionRA.Projection,
	subscriptions *subscriptions,
	updateNotificationContainer *notification.UpdateNotificationContainer,
	retrieveNotificationContainer *notification.RetrieveNotificationContainer,
	timeoutForRequests time.Duration,
	closeFunc func(),
) *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) 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 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