Giter VIP home page Giter VIP logo

Comments (4)

joshuap avatar joshuap commented on August 15, 2024

Ah yeah, the reason I did that is the configuration is passed as a pointer to several other instances such as the worker here. If I change the pointer on the client instance it would not update any of the associated pointers (so I opted to change the reference instead, which does make the configuration mutable). Since the configuration can be updated at runtime I was having a hard time deciding how to rebuild other types which depend on it -- I think to be immutable it would need to create a new worker, which is a plausible alternative.

from honeybadger-go.

kostyantyn avatar kostyantyn commented on August 15, 2024

@joshuap what do you think about using Configuration as a pointer everywhere.

For instance, creating a copy of a client, you could pass the configuration from existing one.
client := honeybadger.New(oldClient.Config)

right now you must dereference the pointer:
client := honeybadger.New(*oldClient.Config)

What is the reason that honeybadger.New accepts Configuration as a value and not as a pointer?

from honeybadger-go.

joshuap avatar joshuap commented on August 15, 2024

I think I can do that; it will just require rebuilding the instances which depend on the configuration when Configure is called, otherwise the issue is that the Configuration values change but the objects (like the worker) which already exist don't get the updated values. I'll play with this a bit.

from honeybadger-go.

joshuap avatar joshuap commented on August 15, 2024

I fixed the issue of dereferencing the config in order to update it. I think we're basically not going the functional route, so this seems simpler.

@kostyantyn regarding passing a value rather than a pointer to things like honeybadger.Configure() and honeybadger.New(), I did that because the argument in those cases is used to update the pointer config which is created on the returned Client instance. Passing a pointer would not reduce the number of copies, and I think honeybadger.Configure(honeybadger.Configuration{APIKey: "your api key"}) is a simpler API than honeybadger.Configure(&honeybadger.Configuration{APIKey: "your api key"}) (having to reference a pointer). Thoughts?

from honeybadger-go.

Related Issues (18)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.