Documentation
¶
Index ¶
Constants ¶
View Source
const ( MinuteInterval = "minute" HourInterval = "hour" DayInterval = "day" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DownlinkRepository ¶
type DownlinkRepository interface {
// Save persists multiple downlinks. Downlinks are saved using a transaction.
// If one downlink fails then none will be saved.
// Successful operation is indicated by non-nil error response.
Save(ctx context.Context, dls ...Downlink) ([]Downlink, error)
// RetrieveByThing retrieves downlinks related to a certain thing,
// identified by a given thing ID.
RetrieveByThing(ctx context.Context, thingID string, pm apiutil.PageMetadata) (DownlinksPage, error)
// RetrieveByGroup retrieves downlinks related to a certain group,
// identified by a given group ID.
RetrieveByGroup(ctx context.Context, groupID string, pm apiutil.PageMetadata) (DownlinksPage, error)
// RetrieveByID retrieves the downlink having the provided ID.
RetrieveByID(ctx context.Context, id string) (Downlink, error)
// RetrieveAll retrieves all downlinks.
RetrieveAll(ctx context.Context) ([]Downlink, error)
// Update performs an update to the existing downlink.
// A non-nil error is returned to indicate operation failure.
Update(ctx context.Context, d Downlink) error
// Remove removes downlinks having the provided IDs.
Remove(ctx context.Context, ids ...string) error
// RemoveByThing removes downlinks related to a certain thing,
// identified by a given thing ID.
RemoveByThing(ctx context.Context, thingID string) error
// RemoveByGroup removes downlinks related to a certain group,
// identified by a given group ID.
RemoveByGroup(ctx context.Context, groupID string) error
}
type DownlinksPage ¶
type DownlinksPage struct {
apiutil.PageMetadata
Downlinks []Downlink
}
type Service ¶
type Service interface {
// CreateDownlinks creates downlinks for certain thing identified by the thing ID.
CreateDownlinks(ctx context.Context, token, thingID string, Downlinks ...Downlink) ([]Downlink, error)
// ListDownlinksByThing retrieves data about a subset of downlinks
// related to a certain thing.
ListDownlinksByThing(ctx context.Context, token, thingID string, pm apiutil.PageMetadata) (DownlinksPage, error)
// ListDownlinksByGroup retrieves data about a subset of downlinks
// related to a certain group.
ListDownlinksByGroup(ctx context.Context, token, groupID string, pm apiutil.PageMetadata) (DownlinksPage, error)
// ViewDownlink retrieves data about the downlink identified with the provided ID.
ViewDownlink(ctx context.Context, token, id string) (Downlink, error)
// UpdateDownlink updates the downlink identified by the provided ID.
UpdateDownlink(ctx context.Context, token string, downlink Downlink) error
// RemoveDownlinks removes downlinks identified with the provided IDs.
RemoveDownlinks(ctx context.Context, token string, id ...string) error
// RemoveDownlinksByThing removes downlinks related to the specified thing,
// identified by the provided thing ID.
RemoveDownlinksByThing(ctx context.Context, thingID string) error
// RemoveDownlinksByGroup removes downlinks related to the specified group,
// identified by the provided group ID.
RemoveDownlinksByGroup(ctx context.Context, groupID string) error
// RescheduleTasks reschedules all tasks for things associated with the specified profile ID.
RescheduleTasks(ctx context.Context, profileID string, config map[string]any) error
// LoadAndScheduleTasks loads schedulers and starts them for executing downlinks
LoadAndScheduleTasks(ctx context.Context) error
// Backup retrieves all downlinks for backup purposes.
Backup(ctx context.Context, token string) ([]Downlink, error)
// Restore saves downlinks from a backup.
Restore(ctx context.Context, token string, downlinks []Downlink) error
}
Service specifies an API that must be fullfiled 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, auth protomfx.AuthServiceClient, pub messaging.Publisher, downlinks DownlinkRepository, idp uuid.IDProvider, logger logger.Logger) Service
Click to show internal directories.
Click to hide internal directories.