Documentation
¶
Index ¶
- type Callback
- type Device
- type GormLogger
- type GormWatcher
- 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) Ping() error
- func (s *InMemoryStorage) Save(device *Device) error
- type InProcessWatcher
- type PgWatcher
- type Pingable
- 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) Ping() 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 ¶
type GormLogger struct{}
GormLogger is a custom logger for Gorm, making it use logrus.
func (*GormLogger) Print ¶
func (*GormLogger) Print(v ...interface{})
Print handles log events from Gorm for the custom logger.
type GormWatcher ¶
func NewGormWatcher ¶
func NewGormWatcher(db *gorm.DB, table string) *GormWatcher
func (*GormWatcher) EmitAdd ¶
func (w *GormWatcher) EmitAdd(device *Device)
func (*GormWatcher) EmitDelete ¶
func (w *GormWatcher) EmitDelete(device *Device)
func (*GormWatcher) OnAdd ¶
func (w *GormWatcher) OnAdd(cb Callback)
func (*GormWatcher) OnDelete ¶
func (w *GormWatcher) OnDelete(cb Callback)
func (*GormWatcher) OnReconnect ¶
func (w *GormWatcher) OnReconnect(cb func())
type InMemoryStorage ¶
type InMemoryStorage struct { *InProcessWatcher // contains filtered or unexported fields }
implements Storage interface
func NewMemoryStorage ¶
func NewMemoryStorage() *InMemoryStorage
func (*InMemoryStorage) Close ¶
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 ¶
func (s *InMemoryStorage) GetByPublicKey(publicKey string) (*Device, error)
func (*InMemoryStorage) Open ¶
func (s *InMemoryStorage) Open() error
func (*InMemoryStorage) Ping ¶ added in v0.9.0
func (s *InMemoryStorage) Ping() error
func (*InMemoryStorage) Save ¶
func (s *InMemoryStorage) Save(device *Device) error
type InProcessWatcher ¶
type InProcessWatcher struct {
// contains filtered or unexported fields
}
func NewInProcessWatcher ¶
func NewInProcessWatcher() *InProcessWatcher
func (*InProcessWatcher) EmitAdd ¶
func (w *InProcessWatcher) EmitAdd(device *Device)
func (*InProcessWatcher) EmitDelete ¶
func (w *InProcessWatcher) EmitDelete(device *Device)
func (*InProcessWatcher) OnAdd ¶
func (w *InProcessWatcher) OnAdd(cb Callback)
func (*InProcessWatcher) OnDelete ¶
func (w *InProcessWatcher) OnDelete(cb Callback)
func (*InProcessWatcher) OnReconnect ¶
func (w *InProcessWatcher) OnReconnect(cb func())
type PgWatcher ¶
func (*PgWatcher) EmitDelete ¶
func (*PgWatcher) OnReconnect ¶
func (w *PgWatcher) OnReconnect(cb func())
type SQLStorage ¶
type SQLStorage struct { Watcher // contains filtered or unexported fields }
implements Storage interface
func NewSqlStorage ¶
func NewSqlStorage(u *url.URL) *SQLStorage
func (*SQLStorage) Close ¶
func (s *SQLStorage) Close() error
func (*SQLStorage) Delete ¶
func (s *SQLStorage) Delete(device *Device) error
func (*SQLStorage) GetByPublicKey ¶
func (s *SQLStorage) GetByPublicKey(publicKey string) (*Device, error)
func (*SQLStorage) Open ¶
func (s *SQLStorage) Open() error
func (*SQLStorage) Ping ¶ added in v0.9.0
func (s *SQLStorage) Ping() error
func (*SQLStorage) Save ¶
func (s *SQLStorage) Save(device *Device) error
Click to show internal directories.
Click to hide internal directories.