MCPcopy
hub / github.com/sqlc-dev/sqlc / Open

Method Open

internal/pgx/poolcache/poolcache.go:23–46  ·  view source on GitHub ↗
(ctx context.Context, uri string)

Source from the content-addressed store, hash-verified

21}
22
23func (c *Cache) Open(ctx context.Context, uri string) (*pgxpool.Pool, error) {
24 if c.closed {
25 return nil, fmt.Errorf("poolcache is closed")
26 }
27
28 c.lock.RLock()
29 existing, found := c.pools[uri]
30 c.lock.RUnlock()
31
32 if found {
33 return existing, nil
34 }
35
36 pool, err := pgxpool.New(ctx, uri)
37 if err != nil {
38 return nil, err
39 }
40
41 c.lock.Lock()
42 c.pools[uri] = pool
43 c.lock.Unlock()
44
45 return pool, nil
46}
47
48func (c *Cache) Close() error {
49 c.lock.Lock()

Callers 15

CreateDatabaseMethod · 0.80
AnalyzeMethod · 0.80
EnsureConnMethod · 0.80
TestExpandMySQLFunction · 0.80
TestExpandSQLiteFunction · 0.80
TestFormatFunction · 0.80
TestValidSchemaFunction · 0.80
readConfigFunction · 0.80
VerifyFunction · 0.80
checkSQLMethod · 0.80
parse.goFile · 0.80
fetchMethod · 0.80

Calls

no outgoing calls

Tested by 10

TestExpandMySQLFunction · 0.64
TestExpandSQLiteFunction · 0.64
TestFormatFunction · 0.64
TestValidSchemaFunction · 0.64
TestBooksFunction · 0.64
TestAuthorsFunction · 0.64
TestPreparedFunction · 0.64
TestQueriesFunction · 0.64
TestPreparedFunction · 0.64
TestQueriesFunction · 0.64