service

package
v2.18.0 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2024 License: Apache-2.0, MIT Imports: 50 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddHandler

func AddHandler(ctx context.Context, svr *server.Server, config Config, publicConfiguration PublicConfiguration, fileWatcher *fsnotify.Watcher, logger log.Logger, tracerProvider trace.TracerProvider, goroutinePoolGo func(func()) error) error

func New

func New(ctx context.Context, config Config, fileWatcher *fsnotify.Watcher, logger log.Logger) (*service.Service, error)

func NewDeviceMetadataProjection

func NewDeviceMetadataProjection(deviceID string) eventstore.Model

func NewEventStoreModelFactory

func NewEventStoreModelFactory() func(context.Context, string, string) (eventstore.Model, error)

func NewResourceLinksProjection

func NewResourceLinksProjection(deviceID string) eventstore.Model

func NewResourceProjection

func NewResourceProjection() eventstore.Model

func Register

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

Register registers the handler instance with a gRPC server.

Types

type APIsConfig

type APIsConfig struct {
	GRPC GRPCConfig `yaml:"grpc" json:"grpc"`
}

Config represent application configuration

func (*APIsConfig) Validate

func (c *APIsConfig) Validate() error

type ClientsConfig

type ClientsConfig struct {
	Eventbus               EventBusConfig      `yaml:"eventBus" json:"eventBus"`
	Eventstore             EventStoreConfig    `yaml:"eventStore" json:"eventStore"`
	IdentityStore          IdentityStoreConfig `yaml:"identityStore" json:"identityStore"`
	OpenTelemetryCollector otelClient.Config   `yaml:"openTelemetryCollector" json:"openTelemetryCollector"`
}

func (*ClientsConfig) Validate

func (c *ClientsConfig) Validate() error

type Config

type Config struct {
	HubID                   string              `yaml:"hubID" json:"hubId"`
	Log                     log.Config          `yaml:"log" json:"log"`
	APIs                    APIsConfig          `yaml:"apis" json:"apis"`
	Clients                 ClientsConfig       `yaml:"clients" json:"clients"`
	ExposedHubConfiguration PublicConfiguration `yaml:"publicConfiguration" json:"publicConfiguration"`
}

func (Config) String

func (c Config) String() string

String return string representation of Config

func (*Config) Validate

func (c *Config) Validate() error

type Device

type Device struct {
	ID              string
	Content         *device.Device
	ResourceChanged *events.ResourceChanged
	Metadata        *pb.Device_Metadata
	Endpoints       []*commands.EndpointInformation
}

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)

type EventBusConfig

type EventBusConfig struct {
	GoPoolSize int               `yaml:"goPoolSize" json:"goPoolSize"`
	NATS       natsClient.Config `yaml:"nats" json:"nats"`
}

func (*EventBusConfig) Validate

func (c *EventBusConfig) Validate() error

type EventStoreConfig

type EventStoreConfig struct {
	ProjectionCacheExpiration time.Duration           `yaml:"cacheExpiration" json:"cacheExpiration"`
	Connection                eventstoreConfig.Config `yaml:",inline" json:",inline"`
}

func (*EventStoreConfig) Validate

func (c *EventStoreConfig) Validate() error

type GRPCConfig

type GRPCConfig struct {
	OwnerCacheExpiration time.Duration `yaml:"ownerCacheExpiration" json:"ownerCacheExpiration"`
	server.Config        `yaml:",inline" json:",inline"`
}

func (*GRPCConfig) Validate

func (c *GRPCConfig) Validate() error

type IdentityStoreConfig

type IdentityStoreConfig struct {
	Connection client.Config `yaml:"grpc" json:"grpc"`
}

func (*IdentityStoreConfig) Validate

func (c *IdentityStoreConfig) Validate() error

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) LoadDevicesMetadata added in v2.4.0

func (p *Projection) LoadDevicesMetadata(deviceIDFilter, toReloadDevices strings.Set, onDeviceMetadataProjection func(m *deviceMetadataProjection) error) error
func (p *Projection) LoadResourceLinks(deviceIDFilter, toReloadDevices strings.Set, onResourceLinkProjection func(m *resourceLinksProjection) error) error
func (p *Projection) LoadResourcesWithLinks(resourceIDFilter []*commands.ResourceId, typeFilter strings.Set, toReloadDevices strings.Set, onResource func(*Resource) error) error

func (*Projection) ReloadDevices added in v2.4.0

func (p *Projection) ReloadDevices(ctx context.Context, deviceIDFilter strings.Set)

type PublicConfiguration

type PublicConfiguration struct {
	CAPool        urischeme.URIScheme `yaml:"caPool" json:"caPool" description:"file path to the root certificate in PEM format"`
	OwnerClaim    string              `yaml:"ownerClaim" json:"ownerClaim"`
	DeviceIDClaim string              `yaml:"deviceIDClaim" json:"deviceIdClaim"`

	CoapGateway              string        `yaml:"coapGateway" json:"coapGateway"`
	DefaultCommandTimeToLive time.Duration `yaml:"defaultCommandTimeToLive" json:"defaultCommandTimeToLive"`
	Authority                string        `yaml:"authority" json:"authority"`
	CertificateAuthority     string        `yaml:"certificateAuthority" json:"certificateAuthority"`
	// contains filtered or unexported fields
}

func (PublicConfiguration) ToProto

func (*PublicConfiguration) Validate

func (c *PublicConfiguration) Validate() error

type RequestHandler

type RequestHandler struct {
	pb.UnimplementedGrpcGatewayServer
	pbRD.UnimplementedResourceDirectoryServer
	// contains filtered or unexported fields
}

RequestHandler handles incoming requests.

func NewRequestHandler

func NewRequestHandler(
	hubID string,
	resourceProjection *Projection,
	eventstore eventstore.EventStore,
	publicConfiguration PublicConfiguration,
	ownerCache *clientIS.OwnerCache,
	closeFunc fn.FuncList,
) *RequestHandler

NewRequestHandler factory for new RequestHandler.

func (*RequestHandler) Close

func (r *RequestHandler) Close()

func (*RequestHandler) GetDevices

func (*RequestHandler) GetDevicesMetadata

func (*RequestHandler) GetEvents

func (*RequestHandler) GetHubConfiguration

func (*RequestHandler) GetLatestDeviceETags added in v2.10.0

func (*RequestHandler) GetPendingCommands

func (*RequestHandler) GetResources

type Resource

type Resource struct {
	Resource *commands.Resource
	// contains filtered or unexported fields
}

func (*Resource) GetContent

func (r *Resource) GetContent() *commands.Content

func (*Resource) GetResourceChanged

func (r *Resource) GetResourceChanged() *events.ResourceChanged

type ResourceDirectory

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

func NewResourceDirectory

func NewResourceDirectory(projection *Projection, deviceIds []string) *ResourceDirectory

type ResourceTwin added in v2.6.0

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

func NewResourceTwin added in v2.6.0

func NewResourceTwin(projection *Projection, deviceIds []string) *ResourceTwin

func (*ResourceTwin) GetDevicesMetadata added in v2.6.0

func (*ResourceTwin) GetPendingCommands added in v2.6.0

func (*ResourceTwin) GetResources added in v2.6.0

Jump to

Keyboard shortcuts

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