-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
71 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// Copyright 2016 Tamás Gulácsi. All rights reserved. | ||
// Use of this source code is governed by The MIT License | ||
// found in the accompanying LICENSE file. | ||
|
||
package ora | ||
|
||
import "context" | ||
|
||
const ( | ||
stmtCfgKey = "stmtCfg" | ||
) | ||
|
||
// ctxStmtCfg returns the StmtCfg from the context, and | ||
// whether it exist at all. | ||
func ctxStmtCfg(ctx context.Context) (StmtCfg, bool) { | ||
cfg, ok := ctx.Value(stmtCfgKey).(StmtCfg) | ||
return cfg, ok | ||
} | ||
|
||
// WithStmtCfg returns a new context, with the given cfg that | ||
// can be used to configure several parameters. | ||
// | ||
// WARNING: the StmtCfg must be derived from Cfg(), or NewStmtCfg(), | ||
// as an empty StmtCfg is not usable! | ||
func WithStmtCfg(ctx context.Context, cfg StmtCfg) context.Context { | ||
return context.WithValue(ctx, stmtCfgKey, cfg) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters