Documentation ¶
Overview ¶
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Index ¶
- Constants
- Variables
- func CloseConsumerCluster()
- func Deserialize(buf []byte, opt SerializeOption, obj interface{}) error
- func PostMessage(msg Message, c *Config) (err error)
- func PostMessages(msgs []Message, c *Config) (err error)
- func SendMessage(msg Message, c *Config) (err error)
- func SendMessages(msgs []Message, c *Config) (err error)
- func Serialize(msg Message, opt SerializeOption) ([]byte, error)
- func StartConsumerCluster(khosts string, productKey string, topics []string) error
- type Broker
- type Config
- type Consumer
- type Device
- type Message
- type MessageFactory
- type MessageHandlerFunc
- type Producer
- type Product
- type Rule
- type SerializeOption
- type Tenant
Constants ¶
const ( TopicNameTenant = "sentel-iot-tenant" TopicNameProduct = "sentel-iot-product" TopicNameDevice = "sentel-iot-device" TopicNameRule = "sentel-iot-rule" TopicNameTriger = "sentel-iot-triger" )
const ( MessageBackendKafka = "kafka" MessageBackendRabbit = "rabbitmq" )
const ( ActionCreate = "create" ActionRemove = "remove" ActionUpdate = "update" ActionStart = "start" ActionStop = "stop" )
const ( EventTrigerStart = 0 EventTrigerStop = 1 )
const (
DefaultMessageBackend = MessageBackendRabbit
)
Variables ¶
var (
JSONSerialization = SerializeOption{Format: "json"}
)
Functions ¶
func CloseConsumerCluster ¶
func CloseConsumerCluster()
func Deserialize ¶
func Deserialize(buf []byte, opt SerializeOption, obj interface{}) error
func PostMessage ¶
func PostMessages ¶
func SendMessage ¶
func SendMessages ¶
Types ¶
type Broker ¶
type Broker struct { TopicName string EventType uint32 `json:"eventType"` Payload []byte `json:"payload"` }
Broker
func (*Broker) Deserialize ¶
func (p *Broker) Deserialize(buf []byte, opt SerializeOption) error
type Config ¶
func NewConfigWithViper ¶
func NewConfigWithViper() *Config
type Consumer ¶
type Consumer interface { WithClientId(clientId string) Subscribe(topic string, queueName string, handler MessageHandlerFunc, ctx interface{}) error UnSubscribe(topic string) error Start() error Close() SetMessageFactory(factory MessageFactory) }
func NewConsumer ¶
type Device ¶
type Device struct { TopicName string ProductKey string `json:"productKey"` Id int64 `json:"id"` Name string `json:"name"` SerialNo string `json:"serialno"` Action string `json:"action"` Message string `json:"message"` }
Device
func (*Device) Deserialize ¶
func (p *Device) Deserialize(buf []byte, opt SerializeOption) error
type Message ¶
type Message interface { Topic() string SetTopic(name string) Serialize(opt SerializeOption) ([]byte, error) Deserialize(buf []byte, opt SerializeOption) error }
type MessageFactory ¶
type MessageHandlerFunc ¶
type MessageHandlerFunc func(msg Message, ctx interface{})
type Producer ¶
type Product ¶
type Product struct { TopicName string ProductId string `json:"productId"` Action string `json:"action"` TenantId string `json:"tenantId"` Replicas int32 `json:"replicas"` }
Product
func (*Product) Deserialize ¶
func (p *Product) Deserialize(buf []byte, opt SerializeOption) error
type Rule ¶
type Rule struct { TopicName string RuleName string `json:"rule_name"` ProductId string `json:"product_id"` Action string `json:"action"` Attributes map[string]string `json:"attributes"` }
Rule
func (*Rule) Deserialize ¶
func (p *Rule) Deserialize(buf []byte, opt SerializeOption) error
type SerializeOption ¶
type SerializeOption struct {
Format string
}