Documentation ¶
Index ¶
- Constants
- Variables
- func AsyncProduceMessage(c core.Config, topic string, value sarama.Encoder) error
- func CheckAllRegisteredServices() error
- func RegisterService(name string, configs map[string]string, factory ServiceFactory)
- func SyncProduceMessage(c core.Config, topic string, value sarama.Encoder) error
- type ClientInfo
- type DecodeFeedback
- type HubNodeInfo
- type Metrics
- type NilDecodeFeedback
- type Packet
- type ProtocolService
- type RouteInfo
- type SerializeBuffer
- type SerializeOptions
- type Service
- type ServiceCommand
- type ServiceFactory
- type ServiceInfo
- type ServiceManager
- func (s *ServiceManager) GetAllProtocolServices() []ProtocolService
- func (s *ServiceManager) GetAllServiceInfo() []*ServiceInfo
- func (s *ServiceManager) GetClient(serviceName string, id string) *ClientInfo
- func (s *ServiceManager) GetClients(serviceName string) []*ClientInfo
- func (s *ServiceManager) GetMetrics(serviceName string) map[string]uint64
- func (s *ServiceManager) GetNodeInfo() *HubNodeInfo
- func (s *ServiceManager) GetProtocolServices(name string) []ProtocolService
- func (s *ServiceManager) GetRoute(serviceName string, topic string) *RouteInfo
- func (s *ServiceManager) GetRoutes(serviceName string) []*RouteInfo
- func (s *ServiceManager) GetServicesByName(name string) []Service
- func (s *ServiceManager) GetSession(serviceName string, id string) *SessionInfo
- func (s *ServiceManager) GetSessions(serviceName string, conditions map[string]bool) []*SessionInfo
- func (s *ServiceManager) GetStats(serviceName string) map[string]uint64
- func (s *ServiceManager) GetSubscription(serviceName string, sub string) *SubscriptionInfo
- func (s *ServiceManager) GetSubscriptions(serviceName string) []*SubscriptionInfo
- func (s *ServiceManager) GetTopic(serviceName string, topic string) *TopicInfo
- func (s *ServiceManager) GetTopics(serviceName string) []*TopicInfo
- func (s *ServiceManager) GetVersion() string
- func (s *ServiceManager) KickoffClient(serviceName string, id string) error
- func (s *ServiceManager) Run() error
- func (s *ServiceManager) StartService(name string) error
- func (s *ServiceManager) StopService(id string) error
- type Session
- type SessionInfo
- type SessionObserver
- type Stats
- type SubscriptionInfo
- type TopicInfo
Constants ¶
const ( ServiceCommandStart = 0 ServiceCommandStop = 1 )
Variables ¶
var ( IotErrorNotFound = errors.New("Resource not found") IotErrorAuthFailed = errors.New("Iot authentication failed") )
Functions ¶
func AsyncProduceMessage ¶
func CheckAllRegisteredServices ¶
func CheckAllRegisteredServices() error
CheckAllRegisteredServices check all registered service simplily
func RegisterService ¶
func RegisterService(name string, configs map[string]string, factory ServiceFactory)
RegisterService register service with name and protocol specified
Types ¶
type ClientInfo ¶
ClientInfo
type DecodeFeedback ¶
type DecodeFeedback interface { // SetTruncated should be called if during decoding you notice that // a packet is shorter than internal layer variables SetTruncated() }
type HubNodeInfo ¶
type Metrics ¶
type Metrics struct {
// contains filtered or unexported fields
}
Metrics declarations
func NewMetrics ¶
func (*Metrics) AddMetrics ¶
type NilDecodeFeedback ¶
type NilDecodeFeedback struct{}
func (NilDecodeFeedback) SetTruncated ¶
func (NilDecodeFeedback) SetTruncated()
type Packet ¶
type Packet interface { // PacketType return type name of packet PacketType() string // DecodeFromReader decode packet from given reader DecodeFromReader(r io.Reader, df DecodeFeedback) error // DecodeFromBytes decode packet from given DecodeFromBytes(data []uint8, df DecodeFeedback) error // SerializeTo writes the serialized form of the packet into the serialize buffer SerializeTo(buf SerializeBuffer, opts SerializeOptions) error // Clear clear packet content and payload Clear() // Length return length of the packet Length() int }
type ProtocolService ¶
type ProtocolService interface { // Service Infomation GetServiceInfo() *ServiceInfo // Stats and Metrics GetStats() *Stats GetMetrics() *Metrics // Client GetClients() []*ClientInfo GetClient(id string) *ClientInfo KickoffClient(id string) error // Session GetSessions(conditions map[string]bool) []*SessionInfo GetSession(id string) *SessionInfo // Route info GetRoutes() []*RouteInfo GetRoute(id string) *RouteInfo // Topic info GetTopics() []*TopicInfo GetTopic(id string) *TopicInfo // SubscriptionInfo GetSubscriptions() []*SubscriptionInfo GetSubscription(id string) *SubscriptionInfo }
type SerializeBuffer ¶
type SerializeBuffer interface { // Bytes return the continguous set of bytes Bytes() []byte // PrependBytes return a set of bytes which prepends the curent bytes // in this buffer PrependBytes(num int) ([]byte, error) // AppendBytes return a set of bytes which append the current bytes // in this buffer AppendBytes(num int) ([]byte, error) // Clear reset the SerializeBuffer to a new Clear() error }
type SerializeOptions ¶
type SerializeOptions struct { // Fixlengths determines whether layers should fix the values for any // length field that depends on the payload during serialization FixLengths bool // ComputeChecksums determines wethers layers should recompute checksums // based on their payloads ComputeChecksums bool }
type Service ¶
type Service interface { Info() *ServiceInfo Start() error Stop() }
func CreateService ¶
CreateService create service instance according to service name
type ServiceCommand ¶
type ServiceCommand int
type ServiceFactory ¶
type ServiceInfo ¶
type ServiceInfo struct { ServiceName string Listen string Acceptors uint64 MaxClients uint64 CurrentClients uint64 ShutdownCount uint64 }
ServiceInfo
type ServiceManager ¶
func GetServiceManager ¶
func GetServiceManager() *ServiceManager
GetServiceManager create service manager and all supported service The function should be called in service
func NewServiceManager ¶
func NewServiceManager(c core.Config) (*ServiceManager, error)
NewServiceManager create ServiceManager only in main context
func (*ServiceManager) GetAllProtocolServices ¶
func (s *ServiceManager) GetAllProtocolServices() []ProtocolService
GetAllProtocolServices() return all protocol services
func (*ServiceManager) GetAllServiceInfo ¶
func (s *ServiceManager) GetAllServiceInfo() []*ServiceInfo
GetAllServiceInfo return all service information
func (*ServiceManager) GetClient ¶
func (s *ServiceManager) GetClient(serviceName string, id string) *ClientInfo
GeteClient return client info with specified client id
func (*ServiceManager) GetClients ¶
func (s *ServiceManager) GetClients(serviceName string) []*ClientInfo
GetClients return clients list withspecified service
func (*ServiceManager) GetMetrics ¶
func (s *ServiceManager) GetMetrics(serviceName string) map[string]uint64
GetMetrics return server metrics
func (*ServiceManager) GetProtocolServices ¶
func (s *ServiceManager) GetProtocolServices(name string) []ProtocolService
GetProtocolServiceByname return protocol services by name
func (*ServiceManager) GetRoute ¶
func (s *ServiceManager) GetRoute(serviceName string, topic string) *RouteInfo
GetRoute return route information for specified topic
func (*ServiceManager) GetRoutes ¶
func (s *ServiceManager) GetRoutes(serviceName string) []*RouteInfo
GetRoutes return route table information for specified service
func (*ServiceManager) GetServicesByName ¶
func (s *ServiceManager) GetServicesByName(name string) []Service
GetServicesByName return service instance by name, or matched by part of name
func (*ServiceManager) GetSession ¶
func (s *ServiceManager) GetSession(serviceName string, id string) *SessionInfo
GetSession return specified session information with session id
func (*ServiceManager) GetSessions ¶
func (s *ServiceManager) GetSessions(serviceName string, conditions map[string]bool) []*SessionInfo
GetSessions return all sessions information for specified service
func (*ServiceManager) GetStats ¶
func (s *ServiceManager) GetStats(serviceName string) map[string]uint64
GetStats return server's stats
func (*ServiceManager) GetSubscription ¶
func (s *ServiceManager) GetSubscription(serviceName string, sub string) *SubscriptionInfo
GetSubscription return subscription information for specified topic
func (*ServiceManager) GetSubscriptions ¶
func (s *ServiceManager) GetSubscriptions(serviceName string) []*SubscriptionInfo
GetSubscriptions return subscription informaiton for specified service
func (*ServiceManager) GetTopic ¶
func (s *ServiceManager) GetTopic(serviceName string, topic string) *TopicInfo
GetTopic return topic information for specified topic
func (*ServiceManager) GetTopics ¶
func (s *ServiceManager) GetTopics(serviceName string) []*TopicInfo
GetTopics return topic informaiton for specified service
func (*ServiceManager) KickoffClient ¶
func (s *ServiceManager) KickoffClient(serviceName string, id string) error
Kickoff Client killoff a client from specified service
func (*ServiceManager) Run ¶
func (s *ServiceManager) Run() error
Run launch all serices and wait to terminate
func (*ServiceManager) StartService ¶
func (s *ServiceManager) StartService(name string) error
StartService launch specified service
func (*ServiceManager) StopService ¶
func (s *ServiceManager) StopService(id string) error
StopService stop specified service
type Session ¶
type Session interface { // Identifier get session identifier Identifier() string // Info return session information Info() *SessionInfo // GetService get the service ower for current session Service() Service // Handle indicate service to handle the packet Handle() error // Destroy will release current session Destroy() error // RegisterObserver register observer on session RegisterObserver(SessionObserver) // Get Stats GetStats() *Stats // Get Metrics GetMetrics() *Metrics }
type SessionInfo ¶
type SessionInfo struct { ClientId string CleanSession bool MessageMaxInflight uint64 MessageInflight uint64 MessageInQueue uint64 MessageDropped uint64 AwaitingRel uint64 AwaitingComp uint64 AwaitingAck uint64 CreatedAt string }
SessionInfo
type SessionObserver ¶
type SessionObserver interface { OnGetMountPoint() string OnConnect(s Session, userdata interface{}) error OnDisconnect(s Session, userdta interface{}) error OnPublish(s Session, userdata interface{}) error OnMessage(s Session, userdata interface{}) error OnSubscribe(s Session, userdata interface{}) error OnUnsubscribe(s Session, userdata interface{}) error OnAuthenticate(s Session, username string, password string) error }
type SubscriptionInfo ¶
SubscriptionInfo