Documentation ¶
Index ¶
- type Config
- type Installation
- type InstallationMetadata
- type Persistence
- type SQLLitePersistence
- func (s *SQLLitePersistence) AddInstallations(identity []byte, timestamp int64, installations []*Installation, ...) ([]*Installation, error)
- func (s *SQLLitePersistence) DisableInstallation(identity []byte, installationID string) error
- func (s *SQLLitePersistence) EnableInstallation(identity []byte, installationID string) error
- func (s *SQLLitePersistence) GetActiveInstallations(maxInstallations int, identity []byte) ([]*Installation, error)
- func (s *SQLLitePersistence) GetInstallations(identity []byte) ([]*Installation, error)
- func (s *SQLLitePersistence) SetInstallationMetadata(identity []byte, installationID string, metadata *InstallationMetadata) error
- type Service
- func (s *Service) DisableInstallation(myIdentityKey *ecdsa.PublicKey, installationID string) error
- func (s *Service) EnableInstallation(identity *ecdsa.PublicKey, installationID string) error
- func (s *Service) GetActiveInstallations(identity *ecdsa.PublicKey) ([]*Installation, error)
- func (s *Service) GetOurActiveInstallations(identity *ecdsa.PublicKey) ([]*Installation, error)
- func (s *Service) GetOurInstallations(identity *ecdsa.PublicKey) ([]*Installation, error)
- func (s *Service) ProcessPublicBundle(myIdentityKey *ecdsa.PrivateKey, theirIdentity *ecdsa.PublicKey, ...) ([]*Installation, error)
- func (s *Service) SetInstallationMetadata(identity *ecdsa.PublicKey, installationID string, ...) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Installation ¶
type Installation struct { // Identity is the string identity of the owner Identity string `json:"identity"` // The installation-id of the device ID string `json:"id"` // The last known protocol version of the device Version uint32 `json:"version"` // Enabled is whether the installation is enabled Enabled bool `json:"enabled"` // InstallationMetadata InstallationMetadata *InstallationMetadata `json:"metadata"` }
type InstallationMetadata ¶
type Persistence ¶
type Persistence interface { // GetActiveInstallations returns the active installations for a given identity. GetActiveInstallations(maxInstallations int, identity []byte) ([]*Installation, error) // EnableInstallation enables the installation. EnableInstallation(identity []byte, installationID string) error // DisableInstallation disable the installation. DisableInstallation(identity []byte, installationID string) error // AddInstallations adds the installations for a given identity, maintaining the enabled flag AddInstallations(identity []byte, timestamp int64, installations []*Installation, defaultEnabled bool) ([]*Installation, error) // GetInstallations returns all the installations for a given identity GetInstallations(identity []byte) ([]*Installation, error) // SetInstallationMetadata sets the metadata for a given installation SetInstallationMetadata(identity []byte, installationID string, data *InstallationMetadata) error }
type SQLLitePersistence ¶
type SQLLitePersistence struct {
// contains filtered or unexported fields
}
SQLLitePersistence represents a persistence service tied to an SQLite database
func NewSQLLitePersistence ¶
func NewSQLLitePersistence(db *sql.DB) *SQLLitePersistence
NewSQLLitePersistence creates a new SQLLitePersistence instance, given a path and a key
func (*SQLLitePersistence) AddInstallations ¶
func (s *SQLLitePersistence) AddInstallations(identity []byte, timestamp int64, installations []*Installation, defaultEnabled bool) ([]*Installation, error)
AddInstallations adds the installations for a given identity, maintaining the enabled flag
func (*SQLLitePersistence) DisableInstallation ¶
func (s *SQLLitePersistence) DisableInstallation(identity []byte, installationID string) error
DisableInstallation disable the installation
func (*SQLLitePersistence) EnableInstallation ¶
func (s *SQLLitePersistence) EnableInstallation(identity []byte, installationID string) error
EnableInstallation enables the installation
func (*SQLLitePersistence) GetActiveInstallations ¶
func (s *SQLLitePersistence) GetActiveInstallations(maxInstallations int, identity []byte) ([]*Installation, error)
GetActiveInstallations returns the active installations for a given identity
func (*SQLLitePersistence) GetInstallations ¶
func (s *SQLLitePersistence) GetInstallations(identity []byte) ([]*Installation, error)
GetInstallations returns all the installations for a given identity
func (*SQLLitePersistence) SetInstallationMetadata ¶
func (s *SQLLitePersistence) SetInstallationMetadata(identity []byte, installationID string, metadata *InstallationMetadata) error
SetInstallationMetadata sets the metadata for a given installation
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
func New ¶
func New(config *Config, persistence Persistence) *Service
func (*Service) DisableInstallation ¶
func (*Service) EnableInstallation ¶
func (*Service) GetActiveInstallations ¶
func (s *Service) GetActiveInstallations(identity *ecdsa.PublicKey) ([]*Installation, error)
func (*Service) GetOurActiveInstallations ¶
func (s *Service) GetOurActiveInstallations(identity *ecdsa.PublicKey) ([]*Installation, error)
func (*Service) GetOurInstallations ¶
func (s *Service) GetOurInstallations(identity *ecdsa.PublicKey) ([]*Installation, error)
func (*Service) ProcessPublicBundle ¶
func (s *Service) ProcessPublicBundle(myIdentityKey *ecdsa.PrivateKey, theirIdentity *ecdsa.PublicKey, b *protobuf.Bundle) ([]*Installation, error)
ProcessPublicBundle persists a bundle and returns a list of tuples identity/installationID