summaryrefslogtreecommitdiff
path: root/internal/events
diff options
context:
space:
mode:
Diffstat (limited to 'internal/events')
-rw-r--r--internal/events/contract.go6
-rw-r--r--internal/events/events.go8
-rw-r--r--internal/events/node.go12
3 files changed, 13 insertions, 13 deletions
diff --git a/internal/events/contract.go b/internal/events/contract.go
index dc5003f..5bea6ac 100644
--- a/internal/events/contract.go
+++ b/internal/events/contract.go
@@ -1,11 +1,11 @@
package events
-import "go.neonxp.dev/djson/internal/model"
+import "go.neonxp.dev/djson/internal/command"
type Dispatcher interface {
- Subscribe(path []string, id string, ch chan model.Mutation)
+ Subscribe(path []string, id string, ch chan command.Mutation)
Unsubscribe(path []string, id string)
- Notify(path []string, event *model.Mutation)
+ Notify(path []string, event *command.Mutation)
}
diff --git a/internal/events/events.go b/internal/events/events.go
index 49731b8..3ee87e4 100644
--- a/internal/events/events.go
+++ b/internal/events/events.go
@@ -3,7 +3,7 @@ package events
import (
"sync"
- "go.neonxp.dev/djson/internal/model"
+ "go.neonxp.dev/djson/internal/command"
)
type stdDispatcher struct {
@@ -14,14 +14,14 @@ func New() Dispatcher {
return &stdDispatcher{
tree: subscriberNode{
children: make(map[string]*subscriberNode),
- channels: make(map[string]chan model.Mutation),
+ channels: make(map[string]chan command.Mutation),
parent: nil,
mu: sync.RWMutex{},
},
}
}
-func (ed *stdDispatcher) Subscribe(path []string, id string, ch chan model.Mutation) {
+func (ed *stdDispatcher) Subscribe(path []string, id string, ch chan command.Mutation) {
ed.tree.subscribe(path, id, ch)
}
@@ -29,6 +29,6 @@ func (ed *stdDispatcher) Unsubscribe(path []string, id string) {
ed.tree.unsubscribe(path, id)
}
-func (ed *stdDispatcher) Notify(path []string, event *model.Mutation) {
+func (ed *stdDispatcher) Notify(path []string, event *command.Mutation) {
ed.tree.notify(path, event)
}
diff --git a/internal/events/node.go b/internal/events/node.go
index a1d9c3e..62d45dd 100644
--- a/internal/events/node.go
+++ b/internal/events/node.go
@@ -3,17 +3,17 @@ package events
import (
"sync"
- "go.neonxp.dev/djson/internal/model"
+ "go.neonxp.dev/djson/internal/command"
)
type subscriberNode struct {
parent *subscriberNode
children map[string]*subscriberNode
- channels map[string]chan model.Mutation
+ channels map[string]chan command.Mutation
mu sync.RWMutex
}
-func (sn *subscriberNode) subscribe(path []string, id string, ch chan model.Mutation) {
+func (sn *subscriberNode) subscribe(path []string, id string, ch chan command.Mutation) {
sn.mu.Lock()
defer sn.mu.Unlock()
if len(path) == 0 {
@@ -26,7 +26,7 @@ func (sn *subscriberNode) subscribe(path []string, id string, ch chan model.Muta
child = &subscriberNode{
parent: sn,
children: make(map[string]*subscriberNode),
- channels: make(map[string]chan model.Mutation),
+ channels: make(map[string]chan command.Mutation),
}
sn.children[head] = child
}
@@ -51,11 +51,11 @@ func (sn *subscriberNode) unsubscribe(path []string, id string) {
}
}
-func (sn *subscriberNode) notify(path []string, event *model.Mutation) {
+func (sn *subscriberNode) notify(path []string, event *command.Mutation) {
sn.mu.RLock()
defer sn.mu.RUnlock()
for _, ch := range sn.channels {
- go func(ch chan model.Mutation) {
+ go func(ch chan command.Mutation) {
ch <- *event
}(ch)
}