-
Notifications
You must be signed in to change notification settings - Fork 111
/
catalog.go
47 lines (39 loc) · 1.32 KB
/
catalog.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package catalog
import (
"context"
"time"
"github.com/rilldata/rill/runtime/drivers"
"github.com/rilldata/rill/runtime/pkg/dag"
)
type Service struct {
Catalog drivers.CatalogStore
Repo drivers.RepoStore
Olap drivers.OLAPStore
InstId string
// temporary information. should this be persisted into olap?
// LastMigration stores the last time migrate was run. Used to filter out repos that didnt change since this time
LastMigration time.Time
dag *dag.DAG
// used to get path when we only have name. happens when we get name from DAG
// TODO: should we add path to the DAG instead
NameToPath map[string]string
// used to get last logged name when parsing fails
PathToName map[string]string
}
func NewService(catalog drivers.CatalogStore, repo drivers.RepoStore, olap drivers.OLAPStore, instId string) *Service {
return &Service{
Catalog: catalog,
Repo: repo,
Olap: olap,
InstId: instId,
dag: dag.NewDAG(),
NameToPath: make(map[string]string),
PathToName: make(map[string]string),
}
}
func (s *Service) FindEntries(ctx context.Context, typ drivers.ObjectType) []*drivers.CatalogEntry {
return s.Catalog.FindEntries(ctx, s.InstId, typ)
}
func (s *Service) FindEntry(ctx context.Context, name string) (*drivers.CatalogEntry, bool) {
return s.Catalog.FindEntry(ctx, s.InstId, name)
}