Skip to content

Commit

Permalink
add RegisterDial function and update README.md file
Browse files Browse the repository at this point in the history
  • Loading branch information
sijms committed May 22, 2024
1 parent dced52e commit ed90a16
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 6 deletions.
35 changes: 29 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -605,13 +605,22 @@ complete code for mapping refcursor to sql.Rows is found in [example/refcursor_t

* ### use custom configurations for connection
* another way to set connection configuration instead of using connection string (DSN)
* use as follow
* for custom dial you should implement `DialerContext` interface or simply use `config.RegisterDial` function (start from v2.8.19)
* example code:
```golang
config, err := go_ora.ParseConfig(DSN)
// modify config structure
go_ora.RegisterConnConfig(config)
// now open db note empty DSN
db, err := sql.Open("oracle", "")
config, err := go_ora.ParseConfig(DSN)

// for using custom dial use RegisterDial
// start from v2.8.19
config.RegisterDial(func(ctx context.Context, network, address string) (net.Conn, error) {
// your custom dial code
})

// modify config structure

go_ora.RegisterConnConfig(config)
// now open db note empty DSN
db, err := sql.Open("oracle", "")
```


Expand Down Expand Up @@ -653,6 +662,20 @@ complete code for mapping refcursor to sql.Rows is found in [example/refcursor_t
### releases
<details>

### version 2.8.19
* add support for long input:
* if input parameter (string or []byte) larger than 32Kb the driver will swith type to `LongVarchar` and `LongRaw`
* so now you can input data with size up to 1 GB that fit into LONG and LOB columns
* add function `RegisterDial` to the configuration object that accept func input
```golang
config, err := go_ora.ParseConfig(`yours DSN string`)
config.RegisterDial(func(ctx context.Context, network, address string) (net.Conn, error) {
// your custom dial code
})
go_ora.RegisterConfig(config)
db, err := sql.Open("oracle", "")
```

### version 2.8.12
* add 2 functions
* ParseConfig
Expand Down
13 changes: 13 additions & 0 deletions v2/configurations/session_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,19 @@ type SessionInfo struct {
Dialer DialerContext
}

func (si *SessionInfo) RegisterDial(dialer func(ctx context.Context, network, address string) (net.Conn, error)) {
var temp = &customDial{DialCtx: dialer}
si.Dialer = temp
}

type customDial struct {
DialCtx func(ctx context.Context, network, address string) (net.Conn, error)
}

func (c *customDial) DialContext(ctx context.Context, network, address string) (net.Conn, error) {
return c.DialCtx(ctx, network, address)
}

func (si *SessionInfo) UpdateSSL(server *ServerAddr) error {
if server != nil {
if strings.ToLower(server.Protocol) == "tcps" {
Expand Down

0 comments on commit ed90a16

Please sign in to comment.