dogstatsd-rs icon indicating copy to clipboard operation
dogstatsd-rs copied to clipboard

Convert public API to builder pattern

Open mcasper opened this issue 7 years ago • 4 comments

Trying to provide a clean API that has lots of optional fields is pretty verbose right now, as was made clear by service checks, not to mention all the options that events support that we should add. My thought is to transition the API to more of a builder pattern, so that you never have to specify the optional arguments that you don't care about:

client.service_check("redis.can_connect", ServiceStatus::OK)
    .hostname("my-host.localhost")
    .timestamp(1510327616)
    .send()

or

client.gauge("my_gauge", "12345")
    .tag("special:tag")
    .send()

mcasper avatar Nov 10 '17 15:11 mcasper

I was thinking the same thing around the Options struct. My current PR that adds default_tags to Options and Client has breaking code changes for anyone bumping the dependency, using a builder pattern here would make future changes a little easier to uptake.

I was thinking something along these lines. If you are in agreement I can either include both changes in the single PR or open the builder after the other one is merged.

dwdking avatar Apr 09 '22 20:04 dwdking

I think opening that up as a separate PR would be great!

mcasper avatar Apr 13 '22 20:04 mcasper

I think opening that up as a separate PR would be great!

Opened the PR.

On an unrelated note is there a road-map or a planned time when you might release a new version of the crate with this and the previous PR that added the default tags?

dwdking avatar Apr 23 '22 01:04 dwdking

@dwdking I just merged the options builder PR and released a new version! (0.7.0)

mcasper avatar Apr 25 '22 17:04 mcasper