Documentation
¶
Index ¶
- Constants
- Variables
- func DecodeModifierParameter(parameter string) (result map[string][]string, err error)
- func SplitModifier(id string) (pureId string, modifier map[string][]string)
- func TrimIdModifier(id string) (pureId string)
- type AsyncCommandHandler
- type CommandRequestMsg
- type CommandResponseMsg
- type Config
- type Connector
- func (this *Connector) CleanMsg(msg map[string]interface{}, service model.Service) (map[string]interface{}, error)
- func (this *Connector) GetProducer(qos Qos) (producer kafka.ProducerInterface, err error)
- func (this *Connector) HandleClientError(userId string, clientId string, errorMessage string)
- func (this *Connector) HandleCommandError(userId string, commandRequest model.ProtocolMsg, errorMessage string)
- func (this *Connector) HandleCommandResponse(commandRequest model.ProtocolMsg, commandResponse CommandResponseMsg, qos Qos) (err error)
- func (this *Connector) HandleDeviceError(userId string, device model.Device, errorMessage string)
- func (this *Connector) HandleDeviceEvent(username string, password string, deviceId string, serviceId string, ...) (err error)
- func (this *Connector) HandleDeviceEventWithAuthToken(token security.JwtToken, deviceId string, serviceId string, eventMsg EventMsg, ...) (err error)
- func (this *Connector) HandleDeviceIdentEvent(username string, password string, deviceId string, localDeviceId string, ...) (info HandledDeviceInfo, err error)
- func (this *Connector) HandleDeviceIdentEventWithAuthToken(token security.JwtToken, deviceId string, localDeviceId string, ...) (info HandledDeviceInfo, err error)
- func (this *Connector) HandleDeviceRefEvent(username string, password string, deviceUri string, serviceUri string, ...) (info HandledDeviceInfo, err error)
- func (this *Connector) HandleDeviceRefEventWithAuthToken(token security.JwtToken, deviceUri string, serviceUri string, ...) (info HandledDeviceInfo, err error)
- func (this *Connector) InitProducer(ctx context.Context, qosList []Qos) (err error)
- func (this *Connector) Iot() *iot.Iot
- func (this *Connector) Security() Security
- func (this *Connector) SendNotification(message Notification) error
- func (this *Connector) SetAsyncCommandHandler(handler AsyncCommandHandler) *Connector
- func (this *Connector) SetDeviceCommandHandler(handler DeviceCommandHandler) *Connector
- func (this *Connector) Start(ctx context.Context, qosList ...Qos) (err error)
- func (this *Connector) StartConsumer(ctx context.Context) (err error)
- func (this *Connector) ValidateMsg(msg map[string]interface{}, service model.Service) error
- type DeviceCommandHandler
- type DeviceTypeCommand
- type EventMsg
- type HandledDeviceInfo
- type Notification
- type ProtocolSegmentName
- type Qos
- type Security
Constants ¶
View Source
const MutedDeviceErrorsAttribute = "platform/mute-format-error"
View Source
const Seperator = "$"
Variables ¶
View Source
var ErrorUnknownLocalServiceId = errors.New("unknown local service id")
Functions ¶
func DecodeModifierParameter ¶
func TrimIdModifier ¶
Types ¶
type AsyncCommandHandler ¶
type AsyncCommandHandler func(commandRequest model.ProtocolMsg, requestMsg CommandRequestMsg, t time.Time) (err error)
type CommandRequestMsg ¶
type CommandRequestMsg = map[ProtocolSegmentName]string
type CommandResponseMsg ¶
type CommandResponseMsg = map[ProtocolSegmentName]string
type Config ¶
type Config struct {
EventTimeProvider func(msg EventMsg) (EventMsg, time.Time)
KafkaUrl string
KafkaResponseTopic string
KafkaGroupName string
FatalKafkaError bool
Protocol string
DeviceManagerUrl string
DeviceRepoUrl string
PermissionsV2Url string
AuthClientId string //keycloak-client
AuthClientSecret string //keycloak-secret
AuthExpirationTimeBuffer float64
AuthEndpoint string
JwtPrivateKey string
JwtExpiration int64
JwtIssuer string
DeviceExpiration int32
DeviceTypeExpiration int32
TokenCacheExpiration int32
IotCacheUrl []string
TokenCacheUrl []string
Debug bool
SerializationFallback string
Validate bool
ValidateAllowUnknownField bool
ValidateAllowMissingField bool
CharacteristicExpiration int32
PartitionsNum int
ReplicationFactor int
PublishToPostgres bool
PostgresHost string
PostgresPort int
PostgresUser string
PostgresPw string
PostgresDb string
HttpCommandConsumerPort string
AsyncPgThreadMax int
AsyncFlushMessages int
AsyncFlushFrequency time.Duration
AsyncCompression sarama.CompressionCodec
SyncCompression sarama.CompressionCodec
KafkaConsumerMaxWait string
KafkaConsumerMinBytes int
KafkaConsumerMaxBytes int
IotCacheTimeout string
IotCacheMaxIdleConns int
NotificationUrl string
DeviceTypeTopic string
KafkaTopicConfigs map[string][]kafka.ConfigEntry
NotificationsIgnoreDuplicatesWithinS int
NotificationUserOverwrite string
DeveloperNotificationUrl string //optional
MutedUserNotificationTitles []string
InitTopics bool
LogLevel string `json:"log_level"`
Logger *slog.Logger `json:"-"` // optional, will be created if not set
}
func LoadConfig ¶
loads config from json in location and used environment variables (e.g KafkaUrl --> ZOOKEEPER_URL)
type Connector ¶
type Connector struct {
Config Config
IotCache *iot.PreparedCache
// contains filtered or unexported fields
}
func (*Connector) GetProducer ¶
func (this *Connector) GetProducer(qos Qos) (producer kafka.ProducerInterface, err error)
func (*Connector) HandleClientError ¶
func (*Connector) HandleCommandError ¶
func (this *Connector) HandleCommandError(userId string, commandRequest model.ProtocolMsg, errorMessage string)
func (*Connector) HandleCommandResponse ¶
func (this *Connector) HandleCommandResponse(commandRequest model.ProtocolMsg, commandResponse CommandResponseMsg, qos Qos) (err error)
func (*Connector) HandleDeviceError ¶
func (*Connector) HandleDeviceEvent ¶
func (*Connector) HandleDeviceEventWithAuthToken ¶
func (*Connector) HandleDeviceIdentEvent ¶
func (*Connector) HandleDeviceIdentEventWithAuthToken ¶
func (*Connector) HandleDeviceRefEvent ¶
func (*Connector) HandleDeviceRefEventWithAuthToken ¶
func (*Connector) InitProducer ¶
func (*Connector) SendNotification ¶
func (this *Connector) SendNotification(message Notification) error
func (*Connector) SetAsyncCommandHandler ¶
func (this *Connector) SetAsyncCommandHandler(handler AsyncCommandHandler) *Connector
asyncCommandHandler, endpointCommandHandler and deviceCommandHandler are mutual exclusive
func (*Connector) SetDeviceCommandHandler ¶
func (this *Connector) SetDeviceCommandHandler(handler DeviceCommandHandler) *Connector
asyncCommandHandler, endpointCommandHandler and deviceCommandHandler are mutual exclusive
func (*Connector) StartConsumer ¶
type DeviceCommandHandler ¶
type DeviceCommandHandler func(deviceId string, deviceUri string, serviceId string, serviceUri string, requestMsg CommandRequestMsg) (responseMsg CommandResponseMsg, qos Qos, err error)
type DeviceTypeCommand ¶
type EventMsg ¶
type EventMsg = map[ProtocolSegmentName]string
type HandledDeviceInfo ¶
type Notification ¶
type ProtocolSegmentName ¶
type ProtocolSegmentName = string
type Security ¶
type Security interface {
Access() (token security.JwtToken, err error)
ResetAccess()
GenerateUserTokenById(userid string) (token security.JwtToken, err error)
GenerateUserToken(username string) (token security.JwtToken, err error)
ExchangeUserToken(userid string, remoteInfo model.RemoteInfo) (token security.JwtToken, err error)
GetUserToken(username string, password string, remoteInfo model.RemoteInfo) (token security.JwtToken, err error)
GetCachedUserToken(username string, remoteInfo model.RemoteInfo) (token security.JwtToken, err error)
GetUserId(username string) (userid string, err error)
GetUserRoles(userid string) (roles []string, err error)
}
Source Files
¶
Click to show internal directories.
Click to hide internal directories.