MCPcopy Create free account
hub / github.com/brimdata/super / LookupPoolByID

Function LookupPoolByID

db/api/api.go:103–126  ·  view source on GitHub ↗
(ctx context.Context, api Interface, id ksuid.KSUID)

Source from the content-addressed store, hash-verified

101}
102
103func LookupPoolByID(ctx context.Context, api Interface, id ksuid.KSUID) (*pools.Config, error) {
104 b := newBuffer(pools.Config{})
105 query := fmt.Sprintf("from :pools | id == hex('%s')", idToHex(id))
106 q, err := api.Query(ctx, srcfiles.Plain(query))
107 if err != nil {
108 return nil, err
109 }
110 defer q.Pull(true)
111 if err := vio.Copy(b, q); err != nil {
112 return nil, err
113 }
114 switch len(b.results) {
115 case 0:
116 return nil, fmt.Errorf("%s: pool not found", id)
117 case 1:
118 pool, ok := b.results[0].(*pools.Config)
119 if !ok {
120 return nil, fmt.Errorf("internal error: pool record has wrong type: %T", b.results[0])
121 }
122 return pool, nil
123 default:
124 return nil, fmt.Errorf("internal error: multiple pools found with same id: %s", id)
125 }
126}
127
128func LookupBranchByName(ctx context.Context, api Interface, poolName, branchName string) (*db.BranchMeta, error) {
129 b := newBuffer(db.BranchMeta{})

Callers 1

PoolIDMethod · 0.85

Calls 6

PlainFunction · 0.92
CopyFunction · 0.92
idToHexFunction · 0.85
newBufferFunction · 0.70
QueryMethod · 0.65
PullMethod · 0.65

Tested by

no test coverage detected