Documentation
¶
Index ¶
- type Callback
- type Device
- type GormLogger
- type InMemoryStorage
- func (s *InMemoryStorage) Close() error
- func (s *InMemoryStorage) Delete(device *Device) error
- func (s *InMemoryStorage) Get(owner string, name string) (*Device, error)
- func (s *InMemoryStorage) GetByPublicKey(publicKey string) (*Device, error)
- func (s *InMemoryStorage) List(username string) ([]*Device, error)
- func (s *InMemoryStorage) Open() error
- func (s *InMemoryStorage) Save(device *Device) error
- type InProcessWatcher
- type PgWatcher
- type SQLStorage
- func (s *SQLStorage) Close() error
- func (s *SQLStorage) Delete(device *Device) error
- func (s *SQLStorage) Get(owner string, name string) (*Device, error)
- func (s *SQLStorage) GetByPublicKey(publicKey string) (*Device, error)
- func (s *SQLStorage) List(username string) ([]*Device, error)
- func (s *SQLStorage) Open() error
- func (s *SQLStorage) Save(device *Device) error
- type Storage
- type Watcher
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Device ¶
type Device struct {
Owner string `json:"owner" gorm:"type:varchar(100);unique_index:key;primary_key"`
OwnerName string `json:"owner_name"`
OwnerEmail string `json:"owner_email"`
OwnerProvider string `json:"owner_provider"`
Name string `json:"name" gorm:"type:varchar(100);unique_index:key;primary_key"`
PublicKey string `json:"public_key" gorm:"unique_index"`
Address string `json:"address"`
CreatedAt time.Time `json:"created_at" gorm:"column:created_at"`
// metadata about the device during the current session
LastHandshakeTime *time.Time `json:"last_handshake_time"`
ReceiveBytes int64 `json:"received_bytes"`
TransmitBytes int64 `json:"transmit_bytes"`
Endpoint string `json:"endpoint"`
}
type GormLogger ¶ added in v0.3.0
type GormLogger struct{}
GormLogger is a custom logger for Gorm, making it use logrus.
func (*GormLogger) Print ¶ added in v0.3.0
func (*GormLogger) Print(v ...interface{})
Print handles log events from Gorm for the custom logger.
type InMemoryStorage ¶
type InMemoryStorage struct {
*InProcessWatcher
// contains filtered or unexported fields
}
implements Storage interface
func NewMemoryStorage ¶
func NewMemoryStorage() *InMemoryStorage
func (*InMemoryStorage) Close ¶ added in v0.3.0
func (s *InMemoryStorage) Close() error
func (*InMemoryStorage) Delete ¶
func (s *InMemoryStorage) Delete(device *Device) error
func (*InMemoryStorage) Get ¶
func (s *InMemoryStorage) Get(owner string, name string) (*Device, error)
func (*InMemoryStorage) GetByPublicKey ¶ added in v0.4.3
func (s *InMemoryStorage) GetByPublicKey(publicKey string) (*Device, error)
func (*InMemoryStorage) Open ¶ added in v0.3.0
func (s *InMemoryStorage) Open() error
func (*InMemoryStorage) Save ¶
func (s *InMemoryStorage) Save(device *Device) error
type InProcessWatcher ¶ added in v0.4.0
type InProcessWatcher struct {
// contains filtered or unexported fields
}
func NewInProcessWatcher ¶ added in v0.4.0
func NewInProcessWatcher() *InProcessWatcher
func (*InProcessWatcher) EmitAdd ¶ added in v0.4.5
func (w *InProcessWatcher) EmitAdd(device *Device)
func (*InProcessWatcher) EmitDelete ¶ added in v0.4.5
func (w *InProcessWatcher) EmitDelete(device *Device)
func (*InProcessWatcher) OnAdd ¶ added in v0.4.0
func (w *InProcessWatcher) OnAdd(cb Callback)
func (*InProcessWatcher) OnDelete ¶ added in v0.4.0
func (w *InProcessWatcher) OnDelete(cb Callback)
func (*InProcessWatcher) OnReconnect ¶ added in v0.4.0
func (w *InProcessWatcher) OnReconnect(cb func())
type PgWatcher ¶ added in v0.4.0
func NewPgWatcher ¶ added in v0.4.0
func (*PgWatcher) EmitDelete ¶ added in v0.4.5
func (*PgWatcher) OnReconnect ¶ added in v0.4.0
func (w *PgWatcher) OnReconnect(cb func())
type SQLStorage ¶ added in v0.3.0
type SQLStorage struct {
Watcher
// contains filtered or unexported fields
}
implements Storage interface
func NewSqlStorage ¶ added in v0.3.0
func NewSqlStorage(u *url.URL) *SQLStorage
func (*SQLStorage) Close ¶ added in v0.3.0
func (s *SQLStorage) Close() error
func (*SQLStorage) Delete ¶ added in v0.3.0
func (s *SQLStorage) Delete(device *Device) error
func (*SQLStorage) Get ¶ added in v0.3.0
func (s *SQLStorage) Get(owner string, name string) (*Device, error)
func (*SQLStorage) GetByPublicKey ¶ added in v0.4.3
func (s *SQLStorage) GetByPublicKey(publicKey string) (*Device, error)
func (*SQLStorage) List ¶ added in v0.3.0
func (s *SQLStorage) List(username string) ([]*Device, error)
func (*SQLStorage) Open ¶ added in v0.3.0
func (s *SQLStorage) Open() error
func (*SQLStorage) Save ¶ added in v0.3.0
func (s *SQLStorage) Save(device *Device) error
type Storage ¶
type Storage interface {
Watcher
Save(device *Device) error
List(owner string) ([]*Device, error)
Get(owner string, name string) (*Device, error)
GetByPublicKey(publicKey string) (*Device, error)
Delete(device *Device) error
Close() error
Open() error
}
func NewStorage ¶ added in v0.3.0
Click to show internal directories.
Click to hide internal directories.