Skip to content

Commit a348f4b

Browse files
authored
Merge pull request #455 from or-else/patch-2
Added json tags to ConnectOpts to make it serializable
2 parents 493b055 + 2ac3821 commit a348f4b

File tree

2 files changed

+23
-23
lines changed

2 files changed

+23
-23
lines changed

encoding/decoder_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,7 @@ func TestDecodeUnmarshalerPointer(t *testing.T) {
433433
t.Errorf("got error %v, expected nil", err)
434434
}
435435
if !jsonEqual(out, want) {
436-
t.Errorf("got %q, want %q", out, want)
436+
t.Errorf("got %+v, want %+v", out, want)
437437
}
438438
}
439439

@@ -587,7 +587,7 @@ func TestDecodeCustomTypeEncodingPointer(t *testing.T) {
587587
t.Errorf("got error %v, expected nil", err)
588588
}
589589
if !jsonEqual(out, want) {
590-
t.Errorf("got %q, want %q", out, want)
590+
t.Errorf("got %+v, want %+v", out, want)
591591
}
592592
}
593593

session.go

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -24,85 +24,85 @@ type Session struct {
2424
type ConnectOpts struct {
2525
// Address holds the address of the server initially used when creating the
2626
// session. Only used if Addresses is empty
27-
Address string `rethinkdb:"address,omitempty"`
27+
Address string `rethinkdb:"address,omitempty" json:"address,omitempty"`
2828
// Addresses holds the addresses of the servers initially used when creating
2929
// the session.
30-
Addresses []string `rethinkdb:"addresses,omitempty"`
30+
Addresses []string `rethinkdb:"addresses,omitempty" json:"addresses,omitempty"`
3131
// Database is the default database name used when executing queries, this
3232
// value is only used if the query does not contain any DB term
33-
Database string `rethinkdb:"database,omitempty"`
33+
Database string `rethinkdb:"database,omitempty" json:"database,omitempty"`
3434
// Username holds the username used for authentication, if blank (and the v1
3535
// handshake protocol is being used) then the admin user is used
36-
Username string `rethinkdb:"username,omitempty"`
36+
Username string `rethinkdb:"username,omitempty" json:"username,omitempty"`
3737
// Password holds the password used for authentication (only used when using
3838
// the v1 handshake protocol)
39-
Password string `rethinkdb:"password,omitempty"`
39+
Password string `rethinkdb:"password,omitempty" json:"password,omitempty"`
4040
// AuthKey is used for authentication when using the v0.4 handshake protocol
4141
// This field is no deprecated
42-
AuthKey string `rethinkdb:"authkey,omitempty"`
42+
AuthKey string `rethinkdb:"authkey,omitempty" json:"authkey,omitempty"`
4343
// Timeout is the time the driver waits when creating new connections, to
4444
// configure the timeout used when executing queries use WriteTimeout and
4545
// ReadTimeout
46-
Timeout time.Duration `rethinkdb:"timeout,omitempty"`
46+
Timeout time.Duration `rethinkdb:"timeout,omitempty" json:"timeout,omitempty"`
4747
// WriteTimeout is the amount of time the driver will wait when sending the
4848
// query to the server
49-
WriteTimeout time.Duration `rethinkdb:"write_timeout,omitempty"`
49+
WriteTimeout time.Duration `rethinkdb:"write_timeout,omitempty" json:"write_timeout,omitempty"`
5050
// ReadTimeout is the amount of time the driver will wait for a response from
5151
// the server when executing queries.
52-
ReadTimeout time.Duration `rethinkdb:"read_timeout,omitempty"`
52+
ReadTimeout time.Duration `rethinkdb:"read_timeout,omitempty" json:"read_timeout,omitempty"`
5353
// KeepAlivePeriod is the keep alive period used by the connection, by default
5454
// this is 30s. It is not possible to disable keep alive messages
55-
KeepAlivePeriod time.Duration `rethinkdb:"keep_alive_timeout,omitempty"`
55+
KeepAlivePeriod time.Duration `rethinkdb:"keep_alive_timeout,omitempty" json:"keep_alive_timeout,omitempty"`
5656
// TLSConfig holds the TLS configuration and can be used when connecting
5757
// to a RethinkDB server protected by SSL
58-
TLSConfig *tls.Config `rethinkdb:"tlsconfig,omitempty"`
58+
TLSConfig *tls.Config `rethinkdb:"tlsconfig,omitempty" json:"tlsconfig,omitempty"`
5959
// HandshakeVersion is used to specify which handshake version should be
6060
// used, this currently defaults to v1 which is used by RethinkDB 2.3 and
6161
// later. If you are using an older version then you can set the handshake
6262
// version to 0.4
63-
HandshakeVersion HandshakeVersion `rethinkdb:"handshake_version,omitempty"`
63+
HandshakeVersion HandshakeVersion `rethinkdb:"handshake_version,omitempty" json:"handshake_version,omitempty"`
6464
// UseJSONNumber indicates whether the cursors running in this session should
6565
// use json.Number instead of float64 while unmarshaling documents with
6666
// interface{}. The default is `false`.
67-
UseJSONNumber bool
67+
UseJSONNumber bool `json:"use_json_number,omitempty"`
6868
// NumRetries is the number of times a query is retried if a connection
6969
// error is detected, queries are not retried if RethinkDB returns a
7070
// runtime error.
71-
NumRetries int
71+
NumRetries int `json:"num_retries,omitempty"`
7272

7373
// InitialCap is used by the internal connection pool and is used to
7474
// configure how many connections are created for each host when the
7575
// session is created. If zero then no connections are created until
7676
// the first query is executed.
77-
InitialCap int `rethinkdb:"initial_cap,omitempty"`
77+
InitialCap int `rethinkdb:"initial_cap,omitempty" json:"initial_cap,omitempty"`
7878
// MaxOpen is used by the internal connection pool and is used to configure
7979
// the maximum number of connections held in the pool. If all available
8080
// connections are being used then the driver will open new connections as
8181
// needed however they will not be returned to the pool. By default the
8282
// maximum number of connections is 2
83-
MaxOpen int `rethinkdb:"max_open,omitempty"`
83+
MaxOpen int `rethinkdb:"max_open,omitempty" json:"max_open,omitempty"`
8484

8585
// Below options are for cluster discovery, please note there is a high
8686
// probability of these changing as the API is still being worked on.
8787

8888
// DiscoverHosts is used to enable host discovery, when true the driver
8989
// will attempt to discover any new nodes added to the cluster and then
9090
// start sending queries to these new nodes.
91-
DiscoverHosts bool `rethinkdb:"discover_hosts,omitempty"`
91+
DiscoverHosts bool `rethinkdb:"discover_hosts,omitempty" json:"discover_hosts,omitempty"`
9292
// HostDecayDuration is used by the go-hostpool package to calculate a weighted
9393
// score when selecting a host. By default a value of 5 minutes is used.
94-
HostDecayDuration time.Duration
94+
HostDecayDuration time.Duration `json:"host_decay_duration,omitempty"`
9595

9696
// UseOpentracing is used to enable creating opentracing-go spans for queries.
9797
// Each span is created as child of span from the context in `RunOpts`.
9898
// This span lasts from point the query created to the point when cursor closed.
99-
UseOpentracing bool
99+
UseOpentracing bool `json:"use_opentracing,omitempty"`
100100

101101
// Deprecated: This function is no longer used due to changes in the
102102
// way hosts are selected.
103-
NodeRefreshInterval time.Duration `rethinkdb:"node_refresh_interval,omitempty"`
103+
NodeRefreshInterval time.Duration `rethinkdb:"node_refresh_interval,omitempty" json:"node_refresh_interval,omitempty"`
104104
// Deprecated: Use InitialCap instead
105-
MaxIdle int `rethinkdb:"max_idle,omitempty"`
105+
MaxIdle int `rethinkdb:"max_idle,omitempty" json:"max_idle,omitempty"`
106106
}
107107

108108
func (o ConnectOpts) toMap() map[string]interface{} {

0 commit comments

Comments
 (0)