diff options
Diffstat (limited to 'internal/tree/engine.go')
-rw-r--r-- | internal/tree/engine.go | 42 |
1 files changed, 0 insertions, 42 deletions
diff --git a/internal/tree/engine.go b/internal/tree/engine.go deleted file mode 100644 index 0f28eb7..0000000 --- a/internal/tree/engine.go +++ /dev/null @@ -1,42 +0,0 @@ -package tree - -import ( - "context" - "sync" - - "go.neonxp.dev/djson/internal/storage" - "go.neonxp.dev/json/model" -) - -type Engine struct { - Root model.Node - mu sync.RWMutex - storage storage.Storage -} - -func New(storage storage.Storage) *Engine { - return &Engine{ - Root: model.Node{}, - mu: sync.RWMutex{}, - storage: storage, - } -} - -func (t *Engine) Run(ctx context.Context) error { - // Load initial mutations - for m := range t.storage.Load() { - if err := t.execute(&m); err != nil { - return err - } - } - - <-ctx.Done() - return nil -} - -func (t *Engine) Get(nodes []string) (*model.Node, error) { - if len(nodes) == 0 { - return &t.Root, nil - } - return t.Root.Query(nodes) -} |