forked from absmach/magistrala
-
Notifications
You must be signed in to change notification settings - Fork 0
/
states.go
43 lines (34 loc) · 1.07 KB
/
states.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// Copyright (c) Mainflux
// SPDX-License-Identifier: Apache-2.0
package twins
import (
"context"
"time"
)
// State stores actual snapshot of entity's values
type State struct {
TwinID string
ID int64
Definition int
Created time.Time
Payload map[string]interface{}
}
// StatesPage contains page related metadata as well as a list of twins that
// belong to this page.
type StatesPage struct {
PageMetadata
States []State
}
// StateRepository specifies a state persistence API.
type StateRepository interface {
// Save persists the state
Save(ctx context.Context, state State) error
// Update updates the state
Update(ctx context.Context, state State) error
// Count returns the number of states related to state
Count(ctx context.Context, twin Twin) (int64, error)
// RetrieveAll retrieves the subset of states related to twin specified by id
RetrieveAll(ctx context.Context, offset uint64, limit uint64, twinID string) (StatesPage, error)
// RetrieveLast retrieves the last saved state
RetrieveLast(ctx context.Context, twinID string) (State, error)
}