You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I think it would be nice to change the options/configuration API by adding options "constructors", giving the options type a builder API and making the option's fields private. This would:
make it possible to distinguish between unset values and values set to 0 for things like MinConns
make it possible to check that a configuration is valid before trying to connect
funcConnect(context.Context, Options) (Pool, error)
funcConnectOne(context.Context, Options) (Conn, error)
// loads options from a credentials filefuncCredentials(string) (Options, error)
// loads options from environment variablesfuncEnvironment() (Options, error)
// loads options from a dsn stringfuncDSN(string) (Options, error)
typeOptions {
// appends a hostAddHost(string) Options// sets the host replacing any existing hostsHost(string) OptionsUser(string) OptionsDatabase(string) Options// etc. Other methods omitted for brevity// Err returns an error if any of the other methods were called with invalid values.Err() error
}
cfg:=edgedb.Credentials("instance-name")
// orcfg:=edgedb.Environment()
// orcfg:=edgedb.DSN("edgedb://foobar")
cfg.ConnectTimeout(500*time.Milliseconds)
cfg.MinConns(0) // invalid value causes cfg to be unusable and Err() returns the related errorcfg.MaxConns(10)
// user could check for errors if they wantifcfg.Err() !=nil {
// do something about it
}
con, err:=Connect(ctx, cfg)
iferr!=nil {
// cfg.Err() is returned from Connect() if not nil
}
The text was updated successfully, but these errors were encountered:
I think it would be nice to change the options/configuration API by adding options "constructors", giving the options type a builder API and making the option's fields private. This would:
0
for things like MinConnsRelated Discussion
Proposed API
The text was updated successfully, but these errors were encountered: