Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FileGroupsPage ¶
type FileGroupsPage struct {
PageMetadata
Files []FileInfo
}
FileGroupsPage contains page related metadata as well as list of files that belong to this page.
type FileInfo ¶
type FileInfo struct {
Name string `json:"name"`
Class string `json:"class"`
Format string `json:"format"`
Metadata map[string]any `json:"metadata,omitempty"`
Time float64 `json:"time,omitempty"`
}
FileInfo contains information about the file
type FileThingsPage ¶
type FileThingsPage struct {
PageMetadata
Files []FileInfo
}
FileThingsPage contains page related metadata as well as list of files that belong to this page.
type GroupsRepository ¶
type GroupsRepository interface {
// Save stores path in filestore
Save(ctx context.Context, groupID string, fi FileInfo) error
// Update updates path in filestore
Update(ctx context.Context, groupID string, fi FileInfo) error
// Retrieve retrieves path from filestore
Retrieve(ctx context.Context, groupID string, fi FileInfo) (FileInfo, error)
// RetrieveByGroup retrieves files from filestore by group
RetrieveByGroup(ctx context.Context, groupID string, fi FileInfo, pm PageMetadata) (FileGroupsPage, error)
// Remove removes path from filestore
Remove(ctx context.Context, groupID string, fi FileInfo) error
// RemoveByGroup removes all paths from filestore by group ID
RemoveByGroup(ctx context.Context, groupID string) error
}
GroupsRepository represents filestore interface.
type PageMetadata ¶
type PageMetadata struct {
Total uint64
Offset uint64 `json:"offset,omitempty"`
Limit uint64 `json:"limit,omitempty"`
Name string `json:"name,omitempty"`
Order string `json:"order,omitempty"`
Dir string `json:"dir,omitempty"`
Metadata map[string]any `json:"metadata,omitempty"`
}
PageMetadata contains page metadata that helps navigation.
type Service ¶
type Service interface {
// SaveFile stores files in filestore
SaveFile(ctx context.Context, file io.Reader, key string, fi FileInfo) error
// UpdateFile updates file from filestore
UpdateFile(ctx context.Context, key string, fi FileInfo) error
// ViewFile views file from filestore
ViewFile(ctx context.Context, key string, fi FileInfo) ([]byte, error)
// ListFiles retrieves files from filestore by thing
ListFiles(ctx context.Context, key string, fi FileInfo, pm PageMetadata) (FileThingsPage, error)
// RemoveFile removes file from filestore
RemoveFile(ctx context.Context, key string, fi FileInfo) error
// RemoveFiles removes files from filestore by thing ID
RemoveFiles(ctx context.Context, thingID string) error
// SaveGroupFile stores group files in filestore
SaveGroupFile(ctx context.Context, file io.Reader, token, groupID string, fi FileInfo) error
// UpdateGroupFile updates group file from filestore
UpdateGroupFile(ctx context.Context, token, groupID string, fi FileInfo) error
// ViewGroupFile views group file from filestore
ViewGroupFile(ctx context.Context, token, groupID string, fi FileInfo) ([]byte, error)
// ListGroupFiles retrieves files from filestore by group
ListGroupFiles(ctx context.Context, token, groupID string, fi FileInfo, pm PageMetadata) (FileGroupsPage, error)
// RemoveGroupFile removes group file from filestore
RemoveGroupFile(ctx context.Context, token, groupID string, fi FileInfo) error
// RemoveAllFilesByGroup removes group files and
// all files belonging to things related to the given group
RemoveAllFilesByGroup(ctx context.Context, groupID string) error
// ViewGroupFileByKey views group file from filestore using Thing Key
ViewGroupFileByKey(ctx context.Context, thingKey string, fi FileInfo) ([]byte, error)
}
Service specifies an API that must be fulfilled by the domain service implementation, and all of its decorators (e.g. logging & metrics).
func New ¶
func New(tc domain.ThingsClient, thingsRepo ThingsRepository, groupsRepo GroupsRepository) Service
New instantiates the filestore service implementation.
type ThingsRepository ¶
type ThingsRepository interface {
// Save stores path in filestore
Save(ctx context.Context, thingID, groupID string, fi FileInfo) error
// Update updates path in filestore
Update(ctx context.Context, thingID string, fi FileInfo) error
// Retrieve retrieves path from filestore
Retrieve(ctx context.Context, thingID string, fi FileInfo) (FileInfo, error)
// RetrieveByThing retrieves files from filestore by thing
RetrieveByThing(ctx context.Context, thingID string, fi FileInfo, pm PageMetadata) (FileThingsPage, error)
// Remove removes path from filestore
Remove(ctx context.Context, thingID string, fi FileInfo) error
// RemoveByThing removes paths from filestore by thing ID
RemoveByThing(ctx context.Context, thingID string) error
// RemoveByGroup removes paths from filestore by group ID
RemoveByGroup(ctx context.Context, groupID string) error
// RetrieveThingIDsByGroup retrieves thing IDs from filestore by group ID
RetrieveThingIDsByGroup(ctx context.Context, groupID string) ([]string, error)
}
ThingsRepository represents filestore interface.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package api contains API-related concerns: endpoint definitions, middlewares and all resource representations.
|
Package api contains API-related concerns: endpoint definitions, middlewares and all resource representations. |
|
http
Package http contains implementation of kit service HTTP API.
|
Package http contains implementation of kit service HTTP API. |
Click to show internal directories.
Click to hide internal directories.