Closed agunglotto closed 1 year ago
I make a test file for connect_option
package network
import "testing"
func TestExtractServers(t *testing.T) {
text := `(DESCRIPTION=
(ADDRESS_LIST=(LOAD_BALANCE=OFF)(FAILOVER=ON)
(ADDRESS=(PROTOCOL=tcp)(HOST=host_dguard)(PORT=1521))
(ADDRESS=(PROTOCOL=tcp)(HOST=host_active)(PORT=1521))
)
(CONNECT_DATA=(SERVICE_NAME=service)(SERVER=DEDICATED))
)`
t.Log(extractServers(text))
text = `(DESCRIPTION_LIST=(LOAD_BALANCE=off)(FAILOVER=on)
(DESCRIPTION=(CONNECT_TIMEOUT=5)
(ADDRESS=(PROTOCOL=TCP)(HOST=host_dguard)(PORT=1521))
(CONNECT_DATA=(SERVICE_NAME=service)(SERVER=DEDICATED))
)
(DESCRIPTION=(CONNECT_TIMEOUT=5)
(ADDRESS=(PROTOCOL=TCP)(HOST=host_active)(PORT=1521))
(CONNECT_DATA=(SERVICE_NAME=service)(SERVER=DEDICATED))
)
)`
t.Log(extractServers(text))
}
the output
=== RUN TestExtractServers
connect_option_test.go:13: [{tcp host_dguard 1521} {tcp host_active 1521}] <nil>
connect_option_test.go:24: [{TCP host_dguard 1521} {TCP host_active 1521}] <nil>
--- PASS: TestExtractServers (0.00s)
PASS
so go-ora extract same information from both text would you please give me a complete connection string (which produce connection refused) to test other function
Here is an example. The difference is not only in the host names but also in the service names, where the main instance has a servicename and the data guard instance uses servicename_RO (with underscore RO for readonly).
(DESCRIPTION_LIST=(LOAD_BALANCE=off)(FAILOVER=on)
(DESCRIPTION=(CONNECT_TIMEOUT=5)(ADDRESS=(PROTOCOL=TCP)
(HOST=dataguard_host)(PORT=1521))
(CONNECT_DATA=(SERVICE_NAME=SERVICE_RO)(SERVER=DEDICATED)))
(DESCRIPTION=(CONNECT_TIMEOUT=5)(ADDRESS=(PROTOCOL=TCP)
(HOST=active_instance)(PORT=1521))
(CONNECT_DATA=(SERVICE_NAME=SERVICE)(SERVER=DEDICATED))))
I add a fix in v2.7.8 that read server information when it is divided into multiple lines
but driver doesn't support multiple services so it will read the first service occurrence which is SERVICE_RO
and ignore the others
When configuring connections, both following variants are possible and do the same for an Oracle client (and godror):
(DESCRIPTION_LIST=(LOAD_BALANCE=off)(FAILOVER=on) (DESCRIPTION=(CONNECT_TIMEOUT=5) (ADDRESS=(PROTOCOL=TCP)(HOST=host_dguard)(PORT=1521)) (CONNECT_DATA=(SERVICE_NAME=service)(SERVER=DEDICATED)) ) (DESCRIPTION=(CONNECT_TIMEOUT=5) (ADDRESS=(PROTOCOL=TCP)(HOST=host_active)(PORT=1521)) (CONNECT_DATA=(SERVICE_NAME=service)(SERVER=DEDICATED)) ) )
(DESCRIPTION= (ADDRESS_LIST=(LOAD_BALANCE=OFF)(FAILOVER=ON) (ADDRESS=(PROTOCOL=tcp)(HOST=host_dguard)(PORT=1521)) (ADDRESS=(PROTOCOL=tcp)(HOST=host_active)(PORT=1521)) ) (CONNECT_DATA=(SERVICE_NAME=service)(SERVER=DEDICATED)) )
While ADDRESS_LIST works, I get an error for DESCRIPTION_LIST: ORA-12564: TNS connection refused