Documentation ¶
Index ¶
- Variables
- type Announcement
- type AppEUIMetadata
- type AppIDMetadata
- type CacheOptions
- type Metadata
- type PrefixMetadata
- type RedisAnnouncementStore
- func (s *RedisAnnouncementStore) AddMetadata(serviceName, serviceID string, metadata ...Metadata) error
- func (s *RedisAnnouncementStore) Delete(serviceName, serviceID string) error
- func (s *RedisAnnouncementStore) Get(serviceName, serviceID string) (*Announcement, error)
- func (s *RedisAnnouncementStore) GetForAppEUI(appEUI types.AppEUI) (*Announcement, error)
- func (s *RedisAnnouncementStore) GetForAppID(appID string) (*Announcement, error)
- func (s *RedisAnnouncementStore) GetMetadata(serviceName, serviceID string) ([]Metadata, error)
- func (s *RedisAnnouncementStore) List() ([]*Announcement, error)
- func (s *RedisAnnouncementStore) ListService(serviceName string) ([]*Announcement, error)
- func (s *RedisAnnouncementStore) RemoveMetadata(serviceName, serviceID string, metadata ...Metadata) error
- func (s *RedisAnnouncementStore) Set(new *Announcement) error
- type Store
Constants ¶
This section is empty.
Variables ¶
var DefaultCacheOptions = CacheOptions{ ServiceCacheSize: 1000, ServiceCacheExpiration: 10 * time.Minute, ListCacheSize: 10, ListCacheExpiration: 10 * time.Second, }
DefaultCacheOptions are the default CacheOptions
Functions ¶
This section is empty.
Types ¶
type Announcement ¶
type Announcement struct { ID string `redis:"id"` ServiceName string `redis:"service_name"` ServiceVersion string `redis:"service_version"` Description string `redis:"description"` URL string `redis:"url"` Public bool `redis:"public"` NetAddress string `redis:"net_address"` PublicKey string `redis:"public_key"` Certificate string `redis:"certificate"` APIAddress string `redis:"api_address"` MQTTAddress string `redis:"mqtt_address"` AMQPAddress string `redis:"amqp_address"` Metadata []Metadata CreatedAt time.Time `redis:"created_at"` UpdatedAt time.Time `redis:"updated_at"` // contains filtered or unexported fields }
Announcement of a network component
func FromProto ¶
func FromProto(a *pb.Announcement) Announcement
FromProto converts an Announcement protobuf to an Announcement
func (Announcement) ChangedFields ¶
func (a Announcement) ChangedFields() (changed []string)
ChangedFields returns the names of the changed fields since the last call to StartUpdate
func (*Announcement) StartUpdate ¶
func (a *Announcement) StartUpdate()
StartUpdate stores the state of the announcement
func (Announcement) ToProto ¶
func (a Announcement) ToProto() *pb.Announcement
ToProto converts the Announcement to a protobuf Announcement
type AppEUIMetadata ¶
AppEUIMetadata is used to store an AppEUI
func (AppEUIMetadata) MarshalText ¶
func (m AppEUIMetadata) MarshalText() ([]byte, error)
MarshalText implements the encoding.TextMarshaler interface
func (AppEUIMetadata) ToProto ¶
func (m AppEUIMetadata) ToProto() *pb.Metadata
ToProto implements the Metadata interface
type AppIDMetadata ¶
type AppIDMetadata struct {
AppID string
}
AppIDMetadata is used to store an AppID
func (AppIDMetadata) MarshalText ¶
func (m AppIDMetadata) MarshalText() ([]byte, error)
MarshalText implements the encoding.TextMarshaler interface
func (AppIDMetadata) ToProto ¶
func (m AppIDMetadata) ToProto() *pb.Metadata
ToProto implements the Metadata interface
type CacheOptions ¶
type CacheOptions struct { ServiceCacheSize int ServiceCacheExpiration time.Duration ListCacheSize int ListCacheExpiration time.Duration }
CacheOptions used for the cache
type Metadata ¶
type Metadata interface { encoding.TextMarshaler ToProto() *pb.Metadata }
Metadata represents metadata that is stored with an Announcement
func MetadataFromProto ¶
MetadataFromProto converts a protocol buffer metadata to a Metadata
func MetadataFromString ¶
MetadataFromString converts a string to a Metadata
type PrefixMetadata ¶
type PrefixMetadata struct {
Prefix types.DevAddrPrefix
}
PrefixMetadata is used to store a DevAddr prefix
func (PrefixMetadata) MarshalText ¶
func (m PrefixMetadata) MarshalText() ([]byte, error)
MarshalText implements the encoding.TextMarshaler interface
func (PrefixMetadata) ToProto ¶
func (m PrefixMetadata) ToProto() *pb.Metadata
ToProto implements the Metadata interface
type RedisAnnouncementStore ¶
type RedisAnnouncementStore struct {
// contains filtered or unexported fields
}
RedisAnnouncementStore stores Announcements in Redis. - Announcements are stored as a Hash - Metadata is stored in a Set - AppIDs and AppEUIs are indexed with key/value pairs
func (*RedisAnnouncementStore) AddMetadata ¶
func (s *RedisAnnouncementStore) AddMetadata(serviceName, serviceID string, metadata ...Metadata) error
AddMetadata adds metadata to the announcement of the specified service
func (*RedisAnnouncementStore) Delete ¶
func (s *RedisAnnouncementStore) Delete(serviceName, serviceID string) error
Delete an Announcement and its metadata
func (*RedisAnnouncementStore) Get ¶
func (s *RedisAnnouncementStore) Get(serviceName, serviceID string) (*Announcement, error)
Get a specific service Announcement The result *does* include metadata
func (*RedisAnnouncementStore) GetForAppEUI ¶
func (s *RedisAnnouncementStore) GetForAppEUI(appEUI types.AppEUI) (*Announcement, error)
GetForAppEUI returns the last Announcement that contains metadata for the given AppEUI
func (*RedisAnnouncementStore) GetForAppID ¶
func (s *RedisAnnouncementStore) GetForAppID(appID string) (*Announcement, error)
GetForAppID returns the last Announcement that contains metadata for the given AppID
func (*RedisAnnouncementStore) GetMetadata ¶
func (s *RedisAnnouncementStore) GetMetadata(serviceName, serviceID string) ([]Metadata, error)
GetMetadata returns the metadata of the specified service
func (*RedisAnnouncementStore) List ¶
func (s *RedisAnnouncementStore) List() ([]*Announcement, error)
List all Announcements The resulting Announcements do *not* include metadata
func (*RedisAnnouncementStore) ListService ¶
func (s *RedisAnnouncementStore) ListService(serviceName string) ([]*Announcement, error)
ListService lists all Announcements for a given service (router/broker/handler) The resulting Announcements *do* include metadata
func (*RedisAnnouncementStore) RemoveMetadata ¶
func (s *RedisAnnouncementStore) RemoveMetadata(serviceName, serviceID string, metadata ...Metadata) error
RemoveMetadata removes metadata from the announcement of the specified service
func (*RedisAnnouncementStore) Set ¶
func (s *RedisAnnouncementStore) Set(new *Announcement) error
Set a new Announcement or update an existing one The metadata of the announcement is ignored, as metadata should be managed with AddMetadata and RemoveMetadata
type Store ¶
type Store interface { List() ([]*Announcement, error) ListService(serviceName string) ([]*Announcement, error) Get(serviceName, serviceID string) (*Announcement, error) GetMetadata(serviceName, serviceID string) ([]Metadata, error) GetForAppID(appID string) (*Announcement, error) GetForAppEUI(appEUI types.AppEUI) (*Announcement, error) Set(new *Announcement) error AddMetadata(serviceName, serviceID string, metadata ...Metadata) error RemoveMetadata(serviceName, serviceID string, metadata ...Metadata) error Delete(serviceName, serviceID string) error }
Store interface for Announcements
func NewCachedAnnouncementStore ¶
func NewCachedAnnouncementStore(store Store, options CacheOptions) Store
NewCachedAnnouncementStore returns a cache wrapper around the existing store
func NewRedisAnnouncementStore ¶
NewRedisAnnouncementStore creates a new Redis-based Announcement store