diff options
author | NeonXP <i@neonxp.dev> | 2023-01-04 18:44:58 +0300 |
---|---|---|
committer | NeonXP <i@neonxp.dev> | 2023-01-04 18:44:58 +0300 |
commit | 8716ac3e650075525cab7fb5caf1aa62b3efe55b (patch) | |
tree | f34dcb33400ef6bfd7f01b55a04f59784505c506 /internal/tree/core.go | |
parent | e91712e388c530dd5bdfb46f028157a62a60b1e3 (diff) |
Diffstat (limited to 'internal/tree/core.go')
-rw-r--r-- | internal/tree/core.go | 50 |
1 files changed, 0 insertions, 50 deletions
diff --git a/internal/tree/core.go b/internal/tree/core.go deleted file mode 100644 index d2cace3..0000000 --- a/internal/tree/core.go +++ /dev/null @@ -1,50 +0,0 @@ -package tree - -import ( - "sync" - - "go.neonxp.dev/djson/internal/events" - "go.neonxp.dev/djson/internal/storage" - "go.neonxp.dev/json/model" -) - -type stdCore struct { - Root model.ObjectNode - state CoreState - mu sync.RWMutex - storage storage.Storage - eventDispatcher events.Dispatcher -} - -func New(storage storage.Storage, eventsDispatcher events.Dispatcher) Core { - return &stdCore{ - Root: model.ObjectNode{}, - state: Running, - mu: sync.RWMutex{}, - storage: storage, - eventDispatcher: eventsDispatcher, - } -} - -func (t *stdCore) Init() error { - // Load initial mutations - for m := range t.storage.Load() { - if err := t.execute(&m); err != nil { - t.state = Failed - return err - } - } - t.state = Ready - return nil -} - -func (t *stdCore) Get(nodes []string) (model.Node, error) { - if len(nodes) == 0 { - return &t.Root, nil - } - return model.Query(&t.Root, nodes) -} - -func (t *stdCore) State() CoreState { - return t.state -} |