edit: The `App` interface has just one implementation which adds the ~4 builtin "Runnables". It is used to implement 5-10 different services each of which adds its custom "Runnables".
On Wednesday, November 15, 2023 at 7:06:08 AM UTC-5 grant wrote: > I've stumbled upon a set of interfaces that doesn't feel quite right, but > I can't say why exactly. > > ``` > type ( > Named interface { > Name() string > } > App interface { > Named > Run() error > Shutdown() > } > // Runnable typically represents a MQTT or HTTP listener > Runnable interface { > Named > Run(ctx context.Context) error > Shutdown(ctx context.Context) error > } > ) > ``` > There are 5-10 app implementations, each of which implements ~3 > "Runnables" on top of ~4 builtin "Runnables". > > One problem I can see with the above is the ambiguity of `Shutdown` - > shouldn't it suffice to cancel the run context? The most analogous stdlib > construct is probably the http package's server, whose `ListenAndServe` > doesn't take context, but that code probably predates the context package. > > What would be an idiomatic way to design these interfaces? Or is their > mere existence a no-Go? > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/adb2519b-ac38-41df-b267-7562b851cfddn%40googlegroups.com.