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

Function LookupPoolByName

db/api/api.go:61–84  ·  view source on GitHub ↗
(ctx context.Context, api Interface, name string)

Source from the content-addressed store, hash-verified

59}
60
61func LookupPoolByName(ctx context.Context, api Interface, name string) (*pools.Config, error) {
62 b := newBuffer(pools.Config{})
63 query := fmt.Sprintf("from :pools | name == '%s'", name)
64 q, err := api.Query(ctx, srcfiles.Plain(query))
65 if err != nil {
66 return nil, err
67 }
68 defer q.Pull(true)
69 if err := vio.Copy(b, q); err != nil {
70 return nil, err
71 }
72 switch len(b.results) {
73 case 0:
74 return nil, fmt.Errorf("%q: pool not found", name)
75 case 1:
76 pool, ok := b.results[0].(*pools.Config)
77 if !ok {
78 return nil, fmt.Errorf("internal error: pool record has wrong type: %T", b.results[0])
79 }
80 return pool, nil
81 default:
82 return nil, fmt.Errorf("internal error: multiple pools found with same name: %s", name)
83 }
84}
85
86func GetPools(ctx context.Context, api Interface) ([]*pools.Config, error) {
87 b := newBuffer(pools.Config{})

Callers 1

PoolIDMethod · 0.85

Calls 5

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

Tested by

no test coverage detected