state: refactor Open to take OpenParams #6520

Merged
merged 1 commit into from Nov 2, 2016

Conversation

Projects
None yet
3 participants
Member

axw commented Nov 1, 2016

Introduce a state.OpenParams struct, and
update state.Open to use it. Add a Clock
parameter while we're at it.

A followup will introduce an observer for
recording mgo/txn-related metrics.

state: refactor Open to take OpenParams
Introduce a state.OpenParams struct, and
update state.Open to use it. Add a Clock
parameter while we're at it.

LGTM \o/
Please clarify what happens if dial-opts is nil: either there is some default or it is not valid.
Apart from ^^ PR looks amazing!

@@ -298,7 +299,13 @@ LXC_BRIDGE="ignored"`[1:])
info, ok := cfg.MongoInfo()
c.Assert(ok, jc.IsTrue)
c.Assert(info.Password, gc.Not(gc.Equals), testing.DefaultMongoPassword)
- st1, err := state.Open(newCfg.Model(), newCfg.Controller(), info, mongotest.DialOpts(), nil)
+ st1, err := state.Open(state.OpenParams{
@anastasiamac

anastasiamac Nov 1, 2016

Member

\o/ So much more understandable/readable with structs :D

+
+ // MongoDialOpts is the mongo.DialOpts used to control how
+ // Mongo connections are made.
+ MongoDialOpts mongo.DialOpts
@anastasiamac

anastasiamac Nov 1, 2016

Member

Please either comment what would happen if dialopts are nil or add to validation to ensure that it does not happen.

@axw

axw Nov 1, 2016

Member

It cannot be nil, it's a struct type.

@anastasiamac

anastasiamac Nov 1, 2016

Member

Oh I see. I've read a ghosted asterix :)

-) (*State, error) {
- st, err := open(controllerModelTag, info, opts, newPolicy, clock.WallClock)
+func Open(args OpenParams) (*State, error) {
+ if err := args.Validate(); err != nil {
@anastasiamac

anastasiamac Nov 1, 2016

Member

Thank you!!!

Member

axw commented Nov 1, 2016

$$merge$$

Contributor

jujubot commented Nov 1, 2016

Status: merge request accepted. Url: http://juju-ci.vapour.ws:8080/job/github-merge-juju

Contributor

jujubot commented Nov 1, 2016

Build failed: Tests failed
build url: http://juju-ci.vapour.ws:8080/job/github-merge-juju/9590

@axw axw referenced this pull request Nov 1, 2016

Merged

Introduce mongo/txnmetrics #6521

Member

axw commented Nov 2, 2016

$$merge$$

Contributor

jujubot commented Nov 2, 2016

Status: merge request accepted. Url: http://juju-ci.vapour.ws:8080/job/github-merge-juju

@jujubot jujubot merged commit 04a449b into juju:develop Nov 2, 2016

1 check passed

github-check-merge-juju Built PR, ran unit tests, and tested LXD deploy.
Details

jujubot added a commit that referenced this pull request Nov 16, 2016

Merge pull request #6521 from axw/state-txn-metrics
Introduce mongo/txnmetrics

This branch introduces a Prometheus collector for mgo/txn operation counts grouped by (database, collection, operation-type, error-result).

This requires juju/txn#21 and #6520.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment