Commit Graph

11 Commits (a31518de9c407dd81746cb022b8eff02c586d61b)

Author SHA1 Message Date
Tim Raymond 9c7c116650 Make argument order of setRandomDefault consistent
Most of the other private CRUD methods have a consistent argument order
of a context, a source, then a transaction. setRandomDefault had two of
these args transposed, so this swaps them to be consistent with the rest
of the methods.
2016-11-08 12:29:29 -05:00
Tim Raymond 5e39e4602a Make context.Context the first argument
This is the convention.
2016-11-08 12:14:06 -05:00
Tim Raymond ff5f57cecc Prevent deadlocks with source default enforcement
Previously, the logic to enforce on default source relied on the
public-facing CRUD methods already provided by SourcesStore. This was
prone to deadlocks due to the possibility of acquiring a transaction
within a transaction.  This extracts the logic that was performed within
the transactions of each CRUD action and makes the private methods that
receive a *bolt.Tx.  This allows the convenience methods that enforce
default source to use this private API and provide the transaction from
its caller. This ensures that there is only ever one transaction
acquired by each expored
CRUD method.
2016-11-08 12:09:35 -05:00
Tim Raymond 3191ef31d2 Enforce default constraints on first/last source
Whenver sources are present, there should be exactly one default source.
Prior to this commit, it was possible to add the first source as a
non-default source and circumvent this invariant. This unfortunately
requires a bit of special-casing logic in s.Add and requires a query to
fetch the number of sources currently persisted.

Tests have been added to cover this as well as deleting the final
source, to ensure that there aren't any odd indexing panics that might
result from trying to find another candidate default source when
deleting.
2016-11-07 18:13:23 -05:00
Tim Raymond 44dd7665ea Extract Default source enforcement logic
Enforcing the constraint that there be exactly one default source
whenever there are sources present isn't really a concern of the
traditional CRUD methods that are provided by SourcesStore. This makes
this separation a little more explicit and provides a place to glue some
documentation onto what would otherwise be a confusing bit of business
logic in the write path of SourcesStore.
2016-11-07 18:13:23 -05:00
Tim Raymond 0108323f04 Auto-set default source on Add and Delete
Previously, when adding a new default source, it was possible to create
more than one default source, since the previous default would not be unset.

Implementing this revealed another issue where deleting the default
source would leave no default set. If the default source is deleted now,
another source is chosen to be the new default.
2016-11-07 18:13:23 -05:00
Tim Raymond bccc4976b6 Enforce single default source on update
This ensures that there will only be on default source upon setting a
new default by unsetting the default flag on all other sources. This
only happens when the source to be updated has Default set to true to
avoid a performance hit when updating other attributes.
2016-11-07 18:13:23 -05:00
Chris Goller d1359c09b3 Refactor to remove autogenerated code. 2016-10-26 22:10:52 -05:00
Chris Goller 91eec23099 Update name to chronograf 2016-10-20 09:39:40 -05:00
Chris Goller f8fe71c5b9 Add kapacitors endpoint (persist/proxy/rest) 2016-10-04 12:48:36 -05:00
Chris Goller 583d8b4f74 Add persistence to sources and use bolt by default 2016-09-30 15:39:27 -05:00