Documentation
¶
Index ¶
Constants ¶
View Source
const ( ReadCoilsFunc = "ReadCoils" // 0x01 ReadDiscreteInputsFunc = "ReadDiscreteInputs" // 0x02 ReadHoldingRegistersFunc = "ReadHoldingRegisters" // 0x03 ReadInputRegistersFunc = "ReadInputRegisters" // 0x04 ByteOrderABCD = "ABCD" // Big-endian (standard network order) ByteOrderDCBA = "DCBA" // Little-endian (x86, ARM in little-endian mode) ByteOrderCDAB = "CDAB" // Middle-endian (PDP-style) ByteOrderBADC = "BADC" // Byte-swapped (less common, but used in some contexts) )
View Source
const ( BoolType = "bool" Int16Type = "int16" Int32Type = "int32" Uint16Type = "uint16" Uint32Type = "uint32" Float32Type = "float32" StringType = "string" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ClientRepository ¶
type ClientRepository interface {
// Save persists multiple Modbus clients.
// Clients are saved using a transaction.
// If one client fails, then none will be saved.
// Successful operation is indicated by non-nil error response.
Save(ctx context.Context, dls ...Client) ([]Client, error)
// RetrieveByThing retrieves clients related to
// a certain thing identified by a given ID.
RetrieveByThing(ctx context.Context, thingID string, pm apiutil.PageMetadata) (ClientsPage, error)
// RetrieveByGroup retrieves Modbus clients related to
// a certain group identified by a given ID.
RetrieveByGroup(ctx context.Context, groupID string, pm apiutil.PageMetadata) (ClientsPage, error)
// RetrieveByID retrieves a client having the provided ID.
RetrieveByID(ctx context.Context, id string) (Client, error)
// RetrieveAll retrieves all clients.
RetrieveAll(ctx context.Context) ([]Client, error)
// Update performs an update to the existing client.
// A non-nil error is returned to indicate operation failure.
Update(ctx context.Context, w Client) error
// Remove removes Modbus clients having the provided IDs.
Remove(ctx context.Context, ids ...string) error
// RemoveByThing removes Modbus clients related to
// a certain thing identified by a given thing ID.
RemoveByThing(ctx context.Context, thingID string) error
// RemoveByGroup removes Modbus clients related to
// a certain group identified by a given group ID.
RemoveByGroup(ctx context.Context, groupID string) error
}
type ClientsPage ¶
type ClientsPage struct {
apiutil.PageMetadata
Clients []Client
}
type Service ¶
type Service interface {
// CreateClients creates clients for certain thing identified by the thing ID.
CreateClients(ctx context.Context, token, thingID string, Clients ...Client) ([]Client, error)
// ListClientsByThing retrieves data about a subset of clients
// related to a certain thing.
ListClientsByThing(ctx context.Context, token, thingID string, pm apiutil.PageMetadata) (ClientsPage, error)
// ListClientsByGroup retrieves data about a subset of clients
// related to a certain group.
ListClientsByGroup(ctx context.Context, token, groupID string, pm apiutil.PageMetadata) (ClientsPage, error)
// ViewClient retrieves data about a client identified with the provided ID.
ViewClient(ctx context.Context, token, id string) (Client, error)
// UpdateClient updates client identified by the provided ID.
UpdateClient(ctx context.Context, token string, client Client) error
// RemoveClients removes clients identified with the provided IDs.
RemoveClients(ctx context.Context, token string, id ...string) error
// RemoveClientsByThing removes clients related to the specified thing,
// identified by the provided thing ID.
RemoveClientsByThing(ctx context.Context, thingID string) error
// RemoveClientsByGroup removes clients related to the specified group,
// identified by the provided group ID.
RemoveClientsByGroup(ctx context.Context, groupID string) error
// RescheduleTasks reschedules all tasks for things related to the specified profile ID.
RescheduleTasks(ctx context.Context, profileID string, config map[string]any) error
// LoadAndScheduleTasks loads schedulers and starts them to execute requests based on client configuration.
LoadAndScheduleTasks(ctx context.Context) error
}
Service specifies an API that must be fulfilled by the domain service implementation, and all of its decorators (e.g. logging & metrics). All methods that accept a token parameter use it to identify and authorize the user performing the operation.
func New ¶
func New(things protomfx.ThingsServiceClient, pub messaging.Publisher, clients ClientRepository, idp uuid.IDProvider, logger logger.Logger) Service
Click to show internal directories.
Click to hide internal directories.