downlinks

package
v0.36.1 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2026 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MinuteInterval = "minute"
	HourInterval   = "hour"
	DayInterval    = "day"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Downlink struct {
	ID         string
	GroupID    string
	ThingID    string
	Name       string
	Url        string
	Method     string
	Payload    []byte
	Headers    map[string]string
	Scheduler  cron.Scheduler
	TimeFilter TimeFilter
	Metadata   Metadata
}

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 Metadata

type Metadata map[string]any

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.

type TimeFilter

type TimeFilter struct {
	StartParam string `json:"start_param"`
	EndParam   string `json:"end_param"`
	Format     string `json:"format"`
	Forecast   bool   `json:"forecast"`
	Interval   string `json:"interval"` // minute | hour | day
	Value      uint   `json:"value"`
}

Directories

Path Synopsis
api

Jump to

Keyboard shortcuts

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