1
0
mirror of https://github.com/mainflux/mainflux.git synced 2025-05-02 22:17:10 +08:00
Darko Draskovic 19503742a6
NOISSUE - Update state based on SenML time value (#1075)
* Update state based on SenML time value

Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com>

* Use Modf to parse SenML rec time

Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com>

* Add Update to State in mocks

Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com>

* Add Delta to Twin Definition and iota consts for state actions

Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com>

* Use action consts for switch statement

Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com>
2020-03-18 19:56:39 +01:00

44 lines
1.0 KiB
Go

// 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(context.Context, State) error
// Update updates the state
Update(context.Context, State) error
// Count returns the number of states related to state
Count(context.Context, Twin) (int64, error)
// RetrieveAll retrieves the subset of states related to twin specified by id
RetrieveAll(ctx context.Context, offset uint64, limit uint64, id string) (StatesPage, error)
// RetrieveLast retrieves the last saved state
RetrieveLast(ctx context.Context, id string) (State, error)
}