Documentation ¶
Index ¶
- Variables
- type ApplicationKey
- type ApplicationKeyType
- type ChannelClient
- type Client
- type DefaultChannelClient
- type DefaultClient
- func (c *DefaultClient) Connect() error
- func (c *DefaultClient) Disconnect()
- func (c *DefaultClient) GetChannel() (*AMQP.Channel, error)
- func (c *DefaultClient) IsConnected() bool
- func (c *DefaultClient) NewPublisher(exchange string) Publisher
- func (c *DefaultClient) NewSubscriber(exchange, name string, durable, autoDelete bool) Subscriber
- type DefaultPublisher
- type DefaultSubscriber
- func (s *DefaultSubscriber) ConsumeUplink(queue string, handler UplinkHandler) error
- func (s *DefaultSubscriber) QueueBind(name, key string) error
- func (s *DefaultSubscriber) QueueDeclare() (string, error)
- func (s *DefaultSubscriber) QueueUnbind(name, key string) error
- func (s *DefaultSubscriber) SubscribeAppDownlink(appID string, handler DownlinkHandler) error
- func (s *DefaultSubscriber) SubscribeAppUplink(appID string, handler UplinkHandler) error
- func (s *DefaultSubscriber) SubscribeDeviceDownlink(appID, devID string, handler DownlinkHandler) error
- func (s *DefaultSubscriber) SubscribeDeviceUplink(appID, devID string, handler UplinkHandler) error
- func (s *DefaultSubscriber) SubscribeDownlink(handler DownlinkHandler) error
- func (s *DefaultSubscriber) SubscribeUplink(handler UplinkHandler) error
- type DeviceKey
- type DeviceKeyType
- type DownlinkHandler
- type Publisher
- type Subscriber
- type UplinkHandler
Constants ¶
This section is empty.
Variables ¶
var ( // ConnectRetries says how many times the client should retry a failed connection ConnectRetries = 10 // ConnectRetryDelay says how long the client should wait between retries ConnectRetryDelay = time.Second )
var ( // PrefetchCount represents the number of messages to prefetch before the AMQP server requires acknowledgment PrefetchCount = 3 // PrefetchSize represents the number of bytes to prefetch before the AMQP server requires acknowledgment PrefetchSize = 0 )
Functions ¶
This section is empty.
Types ¶
type ApplicationKey ¶
type ApplicationKey struct { AppID string Type ApplicationKeyType Field string }
ApplicationKey represents an AMQP topic for applications
func ParseApplicationKey ¶
func ParseApplicationKey(key string) (*ApplicationKey, error)
ParseApplicationKey parses an AMQP application routing key string to an ApplicationKey struct
func (ApplicationKey) String ¶
func (t ApplicationKey) String() string
String implements the Stringer interface
type ApplicationKeyType ¶
type ApplicationKeyType string
ApplicationKeyType represents an AMQP application routing key
const (
AppEvents ApplicationKeyType = "events"
)
Topic types for Applications
type ChannelClient ¶
ChannelClient represents an AMQP channel client
type Client ¶
type Client interface { Connect() error Disconnect() IsConnected() bool NewPublisher(exchange string) Publisher NewSubscriber(exchange, name string, durable, autoDelete bool) Subscriber }
Client connects to an AMQP server
type DefaultChannelClient ¶
type DefaultChannelClient struct {
// contains filtered or unexported fields
}
DefaultChannelClient represents the default client of an AMQP channel
func (*DefaultChannelClient) Close ¶
func (p *DefaultChannelClient) Close() error
Close closes the channel
func (*DefaultChannelClient) Open ¶
func (p *DefaultChannelClient) Open() error
Open opens a new channel and declares the exchange
type DefaultClient ¶
type DefaultClient struct {
// contains filtered or unexported fields
}
DefaultClient is the default AMQP client for The Things Network
func (*DefaultClient) Connect ¶
func (c *DefaultClient) Connect() error
Connect to the AMQP server. It will retry for ConnectRetries times with a delay of ConnectRetryDelay between retries
func (*DefaultClient) Disconnect ¶
func (c *DefaultClient) Disconnect()
Disconnect from the AMQP server
func (*DefaultClient) GetChannel ¶
func (c *DefaultClient) GetChannel() (*AMQP.Channel, error)
GetChannel gets a new AMQP channel
func (*DefaultClient) IsConnected ¶
func (c *DefaultClient) IsConnected() bool
IsConnected returns true if there is a connection to the AMQP server.
func (*DefaultClient) NewPublisher ¶
func (c *DefaultClient) NewPublisher(exchange string) Publisher
NewPublisher returns a new topic publisher on the specified exchange
func (*DefaultClient) NewSubscriber ¶
func (c *DefaultClient) NewSubscriber(exchange, name string, durable, autoDelete bool) Subscriber
NewSubscriber returns a new topic subscriber on the specified exchange
type DefaultPublisher ¶
type DefaultPublisher struct {
DefaultChannelClient
}
DefaultPublisher represents the default AMQP publisher
func (*DefaultPublisher) PublishDownlink ¶
func (c *DefaultPublisher) PublishDownlink(dataDown types.DownlinkMessage) error
PublishDownlink publishes a downlink message to the AMQP broker
func (*DefaultPublisher) PublishUplink ¶
func (c *DefaultPublisher) PublishUplink(dataUp types.UplinkMessage) error
PublishUplink publishes an uplink message to the AMQP broker
type DefaultSubscriber ¶
type DefaultSubscriber struct { DefaultChannelClient // contains filtered or unexported fields }
DefaultSubscriber represents the default AMQP subscriber
func (*DefaultSubscriber) ConsumeUplink ¶
func (s *DefaultSubscriber) ConsumeUplink(queue string, handler UplinkHandler) error
ConsumeUplink consumes uplink messages in a specific queue
func (*DefaultSubscriber) QueueBind ¶
func (s *DefaultSubscriber) QueueBind(name, key string) error
QueueBind binds the routing key to the specified queue
func (*DefaultSubscriber) QueueDeclare ¶
func (s *DefaultSubscriber) QueueDeclare() (string, error)
QueueDeclare declares the queue on the AMQP broker
func (*DefaultSubscriber) QueueUnbind ¶
func (s *DefaultSubscriber) QueueUnbind(name, key string) error
QueueUnbind unbinds the routing key from the specified queue
func (*DefaultSubscriber) SubscribeAppDownlink ¶
func (s *DefaultSubscriber) SubscribeAppDownlink(appID string, handler DownlinkHandler) error
SubscribeAppDownlink subscribes to all downlink messages for the given application
func (*DefaultSubscriber) SubscribeAppUplink ¶
func (s *DefaultSubscriber) SubscribeAppUplink(appID string, handler UplinkHandler) error
SubscribeAppUplink subscribes to all uplink messages for the given application
func (*DefaultSubscriber) SubscribeDeviceDownlink ¶
func (s *DefaultSubscriber) SubscribeDeviceDownlink(appID, devID string, handler DownlinkHandler) error
SubscribeDeviceDownlink subscribes to all downlink messages for the given application and device
func (*DefaultSubscriber) SubscribeDeviceUplink ¶
func (s *DefaultSubscriber) SubscribeDeviceUplink(appID, devID string, handler UplinkHandler) error
SubscribeDeviceUplink subscribes to all uplink messages for the given application and device
func (*DefaultSubscriber) SubscribeDownlink ¶
func (s *DefaultSubscriber) SubscribeDownlink(handler DownlinkHandler) error
SubscribeDownlink subscribes to all downlink messages that the current user has access to
func (*DefaultSubscriber) SubscribeUplink ¶
func (s *DefaultSubscriber) SubscribeUplink(handler UplinkHandler) error
SubscribeUplink subscribes to all uplink messages that the current user has access to
type DeviceKey ¶
type DeviceKey struct { AppID string DevID string Type DeviceKeyType Field string }
DeviceKey represents an AMQP routing key for devices
func ParseDeviceKey ¶
ParseDeviceKey parses an AMQP device routing key string to a DeviceKey struct
type DeviceKeyType ¶
type DeviceKeyType string
DeviceKeyType represents the type of a device topic
const ( DeviceEvents DeviceKeyType = "events" DeviceUplink DeviceKeyType = "up" DeviceDownlink DeviceKeyType = "down" )
Topic types for Devices
type DownlinkHandler ¶
type DownlinkHandler func(subscriber Subscriber, appID string, devID string, req types.DownlinkMessage)
DownlinkHandler is called for downlink messages
type Publisher ¶
type Publisher interface { ChannelClient PublishUplink(dataUp types.UplinkMessage) error PublishDownlink(dataDown types.DownlinkMessage) error }
Publisher represents a publisher for uplink messages
type Subscriber ¶
type Subscriber interface { ChannelClient QueueDeclare() (string, error) QueueBind(name, key string) error QueueUnbind(name, key string) error SubscribeDeviceUplink(appID, devID string, handler UplinkHandler) error SubscribeAppUplink(appID string, handler UplinkHandler) error SubscribeUplink(handler UplinkHandler) error ConsumeUplink(queue string, handler UplinkHandler) error SubscribeDeviceDownlink(appID, devID string, handler DownlinkHandler) error SubscribeAppDownlink(appID string, handler DownlinkHandler) error SubscribeDownlink(handler DownlinkHandler) error }
Subscriber represents a subscriber for uplink messages
type UplinkHandler ¶
type UplinkHandler func(subscriber Subscriber, appID string, devID string, req types.UplinkMessage)
UplinkHandler is called for uplink messages