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/baaf9fc8-0e5f-4178-a8c6-4d89e64e2494n%40googlegroups.com.

Reply via email to