MCPcopy Create free account
hub / github.com/bytebase/bytebase / Open

Method Open

backend/plugin/db/dynamodb/dynamodb.go:49–71  ·  view source on GitHub ↗

Open opens a DynamoDB driver. It must connect to a specific database. If database isn't provided, part of the driver cannot function.

(ctx context.Context, _ storepb.Engine, conf db.ConnectionConfig)

Source from the content-addressed store, hash-verified

47// Open opens a DynamoDB driver. It must connect to a specific database.
48// If database isn't provided, part of the driver cannot function.
49func (d *Driver) Open(ctx context.Context, _ storepb.Engine, conf db.ConnectionConfig) (db.Driver, error) {
50 d.config = conf
51 d.connCtx = conf.ConnectionContext
52
53 cfg, err := util.GetAWSConnectionConfig(ctx, conf)
54 if err != nil {
55 return nil, errors.Wrapf(err, "failed to load AWS config")
56 }
57 d.awsConfig = cfg
58
59 var optFns []func(*dynamodb.Options)
60 // Honor a custom endpoint (e.g. DynamoDB Local) when the data source
61 // specifies a host. Without this the AWS SDK resolves the real AWS endpoint
62 // for the region and the configured host:port is silently ignored, routing
63 // queries intended for a local/compatible endpoint to real AWS.
64 if endpoint := dynamoDBEndpoint(conf.DataSource); endpoint != "" {
65 optFns = append(optFns, func(o *dynamodb.Options) {
66 o.BaseEndpoint = aws.String(endpoint)
67 })
68 }
69 d.client = dynamodb.NewFromConfig(cfg, optFns...)
70 return d, nil
71}
72
73// dynamoDBEndpoint returns a custom DynamoDB endpoint URL derived from the data
74// source host/port, or "" to fall back to the AWS SDK's default (real AWS)

Callers

nothing calls this directly

Implementers 15

MockDriverbackend/plugin/advisor/utils_for_tests
Driverbackend/plugin/db/bigquery/bigquery.go
Driverbackend/plugin/db/mongodb/mongodb.go
Driverbackend/plugin/db/trino/trino.go
Driverbackend/plugin/db/redshift/redshift.go
Driverbackend/plugin/db/oracle/oracle.go
Driverbackend/plugin/db/dynamodb/dynamodb.go
Driverbackend/plugin/db/cosmosdb/cosmosdb.go
Driverbackend/plugin/db/spanner/spanner.go
Driverbackend/plugin/db/mssql/mssql.go
Driverbackend/plugin/db/mysql/mysql.go
Driverbackend/plugin/db/pg/pg.go

Calls 3

GetAWSConnectionConfigFunction · 0.92
dynamoDBEndpointFunction · 0.85
StringMethod · 0.65

Tested by

no test coverage detected