| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- package queue
- import (
- redisqueue "IotAdmin/core/redis-queue"
- "IotAdmin/core/storage"
- "sync"
- )
- type Message struct {
- redisqueue.Message
- ErrorCount int
- mux sync.RWMutex
- }
- func (m *Message) GetID() string {
- return m.ID
- }
- func (m *Message) SetID(id string) {
- m.ID = id
- }
- func (m *Message) GetStream() string {
- m.mux.Lock()
- defer m.mux.Unlock()
- return m.Stream
- }
- func (m *Message) SetStream(stream string) {
- m.mux.Lock()
- defer m.mux.Unlock()
- m.Stream = stream
- }
- func (m *Message) GetValues() map[string]interface{} {
- m.mux.Lock()
- defer m.mux.Unlock()
- return m.Values
- }
- func (m *Message) SetValues(values map[string]interface{}) {
- m.mux.Lock()
- defer m.mux.Unlock()
- m.Values = values
- }
- func (m *Message) GetPrefix() (prefix string) {
- m.mux.Lock()
- defer m.mux.Unlock()
- if m.Values == nil {
- return
- }
- v, _ := m.Values[storage.PrefixKey]
- prefix, _ = v.(string)
- return
- }
- func (m *Message) SetPrefix(prefix string) {
- m.mux.Lock()
- defer m.mux.Unlock()
- if m.Values == nil {
- m.Values = make(map[string]interface{})
- }
- m.Values[storage.PrefixKey] = prefix
- }
- func (m *Message) GetErrorCount() int {
- return m.ErrorCount
- }
- func (m *Message) SetErrorCount(count int) {
- m.ErrorCount = count
- }
|