snapshot of https://github.com/ThreeDotsLabs/watermill.git (master, 2026-09-15; blobs > 131072B omitted)
Some checks failed
master / ci (push) Failing after 0s

This commit is contained in:
upstream-mirror
2026-09-15 21:27:46 +05:00
commit ce933d1277
538 changed files with 46504 additions and 0 deletions

View File

@@ -0,0 +1,35 @@
package main
import (
"sync"
"github.com/ThreeDotsLabs/watermill-routing-example/server/common"
)
type storage struct {
lock *sync.Mutex
receivedMessages map[string][]common.MessageReceived
}
func (s *storage) Append(message common.MessageReceived) {
s.lock.Lock()
defer s.lock.Unlock()
for k, v := range s.receivedMessages {
s.receivedMessages[k] = append(v, message)
}
}
func (s *storage) PopAll(key string) []common.MessageReceived {
s.lock.Lock()
defer s.lock.Unlock()
if _, ok := s.receivedMessages[key]; !ok {
s.receivedMessages[key] = []common.MessageReceived{}
return []common.MessageReceived{}
}
messages := s.receivedMessages[key]
s.receivedMessages[key] = []common.MessageReceived{}
return messages
}