service

package
v2.5.1 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2022 License: Apache-2.0 Imports: 30 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ResourceAggregate_ServiceDesc = grpc.ServiceDesc{
	ServiceName: "resourceaggregate.pb.ResourceAggregate",
	HandlerType: (*ResourceAggregateServer)(nil),
	Methods: []grpc.MethodDesc{
		{
			MethodName: "PublishResourceLinks",
			Handler:    _ResourceAggregate_PublishResourceLinks_Handler,
		},
		{
			MethodName: "UnpublishResourceLinks",
			Handler:    _ResourceAggregate_UnpublishResourceLinks_Handler,
		},
		{
			MethodName: "NotifyResourceChanged",
			Handler:    _ResourceAggregate_NotifyResourceChanged_Handler,
		},
		{
			MethodName: "UpdateResource",
			Handler:    _ResourceAggregate_UpdateResource_Handler,
		},
		{
			MethodName: "ConfirmResourceUpdate",
			Handler:    _ResourceAggregate_ConfirmResourceUpdate_Handler,
		},
		{
			MethodName: "RetrieveResource",
			Handler:    _ResourceAggregate_RetrieveResource_Handler,
		},
		{
			MethodName: "ConfirmResourceRetrieve",
			Handler:    _ResourceAggregate_ConfirmResourceRetrieve_Handler,
		},
		{
			MethodName: "DeleteResource",
			Handler:    _ResourceAggregate_DeleteResource_Handler,
		},
		{
			MethodName: "ConfirmResourceDelete",
			Handler:    _ResourceAggregate_ConfirmResourceDelete_Handler,
		},
		{
			MethodName: "CreateResource",
			Handler:    _ResourceAggregate_CreateResource_Handler,
		},
		{
			MethodName: "ConfirmResourceCreate",
			Handler:    _ResourceAggregate_ConfirmResourceCreate_Handler,
		},
		{
			MethodName: "UpdateDeviceMetadata",
			Handler:    _ResourceAggregate_UpdateDeviceMetadata_Handler,
		},
		{
			MethodName: "ConfirmDeviceMetadataUpdate",
			Handler:    _ResourceAggregate_ConfirmDeviceMetadataUpdate_Handler,
		},
		{
			MethodName: "CancelPendingMetadataUpdates",
			Handler:    _ResourceAggregate_CancelPendingMetadataUpdates_Handler,
		},
		{
			MethodName: "CancelPendingCommands",
			Handler:    _ResourceAggregate_CancelPendingCommands_Handler,
		},
		{
			MethodName: "DeleteDevices",
			Handler:    _ResourceAggregate_DeleteDevices_Handler,
		},
	},
	Streams:  []grpc.StreamDesc{},
	Metadata: "resource-aggregate/pb/service.proto",
}

ResourceAggregate_ServiceDesc is the grpc.ServiceDesc for ResourceAggregate service. It's only intended for direct use with grpc.RegisterService, and not to be introspected or modified (even as a copy)

Functions

func DeviceMetadataFactoryModel

func DeviceMetadataFactoryModel(ctx context.Context) (cqrsAggregate.AggregateModel, error)

func New

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

func NewAggregate

func NewAggregate(resourceID *commands.ResourceId, snapshotThreshold int, eventstore EventStore, factoryModel cqrsAggregate.FactoryModelFunc, retry cqrsAggregate.RetryFunc) (*aggregate, error)

NewAggregate creates new resource aggreate - it must be created for every run command.

func NewService

func NewService(ctx context.Context, config Config, fileWatcher *fsnotify.Watcher, logger log.Logger, tracerProvider trace.TracerProvider, eventStore EventStore, publisher cqrsEventBus.Publisher) (*service.Service, error)

New creates new Server with provided store and publisher.

func PublishEvents

func PublishEvents(publisher eventbus.Publisher, owner, deviceID, resourceID string, events []eventbus.Event) error

func RegisterResourceAggregateServer

func RegisterResourceAggregateServer(s grpc.ServiceRegistrar, srv ResourceAggregateServer)

func ResourceLinksFactoryModel

func ResourceLinksFactoryModel(ctx context.Context) (cqrsAggregate.AggregateModel, error)

func ResourceStateFactoryModel

func ResourceStateFactoryModel(ctx context.Context) (cqrsAggregate.AggregateModel, error)

Types

type APIsConfig

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

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 {
	Log     log.Config    `yaml:"log" json:"log"`
	APIs    APIsConfig    `yaml:"apis" json:"apis"`
	Clients ClientsConfig `yaml:"clients" json:"clients"`
}

Config represent application configuration

func (Config) String

func (c Config) String() string

String return string representation of Config

func (*Config) Validate

func (c *Config) Validate() error

type EventBusConfig

type EventBusConfig struct {
	NATS natsClient.ConfigPublisher `yaml:"nats" json:"nats"`
}

func (*EventBusConfig) Validate

func (c *EventBusConfig) Validate() error

type EventStore

type EventStore interface {
	cqrsEventStore.EventStore
	cqrsMaintenance.EventStore
}

type EventStoreConfig

type EventStoreConfig struct {
	SnapshotThreshold            int                     `yaml:"snapshotThreshold" json:"snapshotThreshold"`
	ConcurrencyExceptionMaxRetry int                     `yaml:"occMaxRetry" json:"occMaxRetry"`
	DefaultCommandTimeToLive     time.Duration           `yaml:"defaultCommandTimeToLive" json:"defaultCommandTimeToLive"`
	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"`
	grpcServer.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 LogPublishErrFunc

type LogPublishErrFunc func(err error)

type RequestHandler

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

RequestHandler for handling incoming request

func NewRequestHandler

func NewRequestHandler(config Config, eventstore EventStore, publisher eventbus.Publisher, getOwnerDevicesFunc getOwnerDevicesFunc) *RequestHandler

NewRequestHandler factory for new RequestHandler

func (RequestHandler) CreateResource

func (RequestHandler) DeleteDevices

Delete documents from events database for devices selected by query

Using empty deviceIdFilter in DeleteDevicesRequest is interpreting as requesting to delete all documents for devices owned by the user.

Function returns error or a non-empty DeleteDevicesResponse message, where the DeviceIds field is filled with list of device ids. The list is an intersection of the list provided by DeleteDevicesRequest and device ids owned by the user (ie. from the original list of device ids it filters out devices that are not owned by the user).

func (RequestHandler) DeleteResource

func (RequestHandler) RetrieveResource

func (RequestHandler) UpdateResource

type ResourceAggregateClient

type ResourceAggregateClient interface {
	PublishResourceLinks(ctx context.Context, in *commands.PublishResourceLinksRequest, opts ...grpc.CallOption) (*commands.PublishResourceLinksResponse, error)
	UnpublishResourceLinks(ctx context.Context, in *commands.UnpublishResourceLinksRequest, opts ...grpc.CallOption) (*commands.UnpublishResourceLinksResponse, error)
	NotifyResourceChanged(ctx context.Context, in *commands.NotifyResourceChangedRequest, opts ...grpc.CallOption) (*commands.NotifyResourceChangedResponse, error)
	UpdateResource(ctx context.Context, in *commands.UpdateResourceRequest, opts ...grpc.CallOption) (*commands.UpdateResourceResponse, error)
	ConfirmResourceUpdate(ctx context.Context, in *commands.ConfirmResourceUpdateRequest, opts ...grpc.CallOption) (*commands.ConfirmResourceUpdateResponse, error)
	RetrieveResource(ctx context.Context, in *commands.RetrieveResourceRequest, opts ...grpc.CallOption) (*commands.RetrieveResourceResponse, error)
	ConfirmResourceRetrieve(ctx context.Context, in *commands.ConfirmResourceRetrieveRequest, opts ...grpc.CallOption) (*commands.ConfirmResourceRetrieveResponse, error)
	DeleteResource(ctx context.Context, in *commands.DeleteResourceRequest, opts ...grpc.CallOption) (*commands.DeleteResourceResponse, error)
	ConfirmResourceDelete(ctx context.Context, in *commands.ConfirmResourceDeleteRequest, opts ...grpc.CallOption) (*commands.ConfirmResourceDeleteResponse, error)
	CreateResource(ctx context.Context, in *commands.CreateResourceRequest, opts ...grpc.CallOption) (*commands.CreateResourceResponse, error)
	ConfirmResourceCreate(ctx context.Context, in *commands.ConfirmResourceCreateRequest, opts ...grpc.CallOption) (*commands.ConfirmResourceCreateResponse, error)
	UpdateDeviceMetadata(ctx context.Context, in *commands.UpdateDeviceMetadataRequest, opts ...grpc.CallOption) (*commands.UpdateDeviceMetadataResponse, error)
	ConfirmDeviceMetadataUpdate(ctx context.Context, in *commands.ConfirmDeviceMetadataUpdateRequest, opts ...grpc.CallOption) (*commands.ConfirmDeviceMetadataUpdateResponse, error)
	CancelPendingMetadataUpdates(ctx context.Context, in *commands.CancelPendingMetadataUpdatesRequest, opts ...grpc.CallOption) (*commands.CancelPendingMetadataUpdatesResponse, error)
	CancelPendingCommands(ctx context.Context, in *commands.CancelPendingCommandsRequest, opts ...grpc.CallOption) (*commands.CancelPendingCommandsResponse, error)
	DeleteDevices(ctx context.Context, in *commands.DeleteDevicesRequest, opts ...grpc.CallOption) (*commands.DeleteDevicesResponse, error)
}

ResourceAggregateClient is the client API for ResourceAggregate service.

For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.

type ResourceAggregateServer

type ResourceAggregateServer interface {
	PublishResourceLinks(context.Context, *commands.PublishResourceLinksRequest) (*commands.PublishResourceLinksResponse, error)
	UnpublishResourceLinks(context.Context, *commands.UnpublishResourceLinksRequest) (*commands.UnpublishResourceLinksResponse, error)
	NotifyResourceChanged(context.Context, *commands.NotifyResourceChangedRequest) (*commands.NotifyResourceChangedResponse, error)
	UpdateResource(context.Context, *commands.UpdateResourceRequest) (*commands.UpdateResourceResponse, error)
	ConfirmResourceUpdate(context.Context, *commands.ConfirmResourceUpdateRequest) (*commands.ConfirmResourceUpdateResponse, error)
	RetrieveResource(context.Context, *commands.RetrieveResourceRequest) (*commands.RetrieveResourceResponse, error)
	ConfirmResourceRetrieve(context.Context, *commands.ConfirmResourceRetrieveRequest) (*commands.ConfirmResourceRetrieveResponse, error)
	DeleteResource(context.Context, *commands.DeleteResourceRequest) (*commands.DeleteResourceResponse, error)
	ConfirmResourceDelete(context.Context, *commands.ConfirmResourceDeleteRequest) (*commands.ConfirmResourceDeleteResponse, error)
	CreateResource(context.Context, *commands.CreateResourceRequest) (*commands.CreateResourceResponse, error)
	ConfirmResourceCreate(context.Context, *commands.ConfirmResourceCreateRequest) (*commands.ConfirmResourceCreateResponse, error)
	UpdateDeviceMetadata(context.Context, *commands.UpdateDeviceMetadataRequest) (*commands.UpdateDeviceMetadataResponse, error)
	ConfirmDeviceMetadataUpdate(context.Context, *commands.ConfirmDeviceMetadataUpdateRequest) (*commands.ConfirmDeviceMetadataUpdateResponse, error)
	CancelPendingMetadataUpdates(context.Context, *commands.CancelPendingMetadataUpdatesRequest) (*commands.CancelPendingMetadataUpdatesResponse, error)
	CancelPendingCommands(context.Context, *commands.CancelPendingCommandsRequest) (*commands.CancelPendingCommandsResponse, error)
	DeleteDevices(context.Context, *commands.DeleteDevicesRequest) (*commands.DeleteDevicesResponse, error)
	// contains filtered or unexported methods
}

ResourceAggregateServer is the server API for ResourceAggregate service. All implementations must embed UnimplementedResourceAggregateServer for forward compatibility

type UnimplementedResourceAggregateServer

type UnimplementedResourceAggregateServer struct {
}

UnimplementedResourceAggregateServer must be embedded to have forward compatible implementations.

type UnsafeResourceAggregateServer

type UnsafeResourceAggregateServer interface {
	// contains filtered or unexported methods
}

UnsafeResourceAggregateServer may be embedded to opt out of forward compatibility for this service. Use of this interface is not recommended, as added methods to ResourceAggregateServer will result in compilation errors.

Jump to

Keyboard shortcuts

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