recentpopularlog in


« earlier   
Airport Baggage Claims, Selective Consumers, and RabbitMQ Anti-Patterns -
On designs based on conditionally reject a message after having received it, by abusing NACK. Of course, RabbitMQ routing should be used to ensure this never happens.
RabbitMQ  messageBrokering  designPatterns  antiPatterns  blogEntries 
12 days ago by MaxBarraclough
Functional options for friendly APIs | Dave Cheney
The key difference from the previous example, and in fact all the examples so far, is customisation of the Server is performed not with configuration parameters stored in a structure, but with functions which operate on the Server value itself. As before, the variadic nature of the function’s signature gives us the compact behaviour for the default case. When configuration is required, I pass to NewServer functions which operate on the Server value as an argument. The timeout function simply changes the timeout field of any *Server value passed to it. The tls function is a little more complicated. It takes a *Server value and wraps the original listener value inside a tls.Listener, thereby transforming it into a secure listener.
api  golang  programming  options  configuration  designpatterns 
13 days ago by dlkinney
Self-referential functions and the design of options
I've been trying on and off to find a nice way to deal with setting options in a Go package I am writing. Options on a type, that is. The package is intricate and there will probably end up being dozens of options. There are many ways to do this kind of thing, but I wanted one that felt nice to use, didn't require too much API (or at least not too much for the user to absorb), and could grow as needed without bloat. I've tried most of the obvious ways: option structs, lots of methods, variant constructors, and more, and found them all unsatisfactory. After a bunch of trial versions over the past year or so, and a lot of conversations with other Gophers making suggestions, I've finally found one I like. You might like it too. Or you might not, but either way it does show an interesting use of self-referential functions.
api  golang  programming  options  configuration  designpatterns 
13 days ago by dlkinney

Copy this bookmark:

to read