mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-17 14:19:54 +05:00
add timestamp before publishing events
This commit is contained in:
@@ -122,6 +122,7 @@ func (ps *PubSub) Unsubscribe(si SubscribeInfo, reply *string) error {
|
||||
func (ps *PubSub) Publish(evt CgrEvent, reply *string) error {
|
||||
ps.mux.Lock()
|
||||
defer ps.mux.Unlock()
|
||||
evt["Timestamp"] = time.Now().Format(time.RFC3339Nano)
|
||||
for key, subData := range ps.subscribers {
|
||||
if !subData.ExpTime.IsZero() && subData.ExpTime.Before(time.Now()) {
|
||||
delete(ps.subscribers, key)
|
||||
|
||||
@@ -137,7 +137,7 @@ func TestPublish(t *testing.T) {
|
||||
t.Error("Error publishing: ", err)
|
||||
}
|
||||
for i := 0; i < 1000; i++ { // wait for the theread to populate map
|
||||
if len(m) == 1 {
|
||||
if len(m) == 2 {
|
||||
time.Sleep(time.Microsecond)
|
||||
} else {
|
||||
break
|
||||
|
||||
Reference in New Issue
Block a user