Skip to content

Conversation

@russellhaering
Copy link

Manners currently has a type switch that it uses to get a file descriptor from various types of listeners:

  1. Listeners from the stdlib net package which have a File() (*os.File, error) method.
  2. Internally defined listener types which mostly wrap net listener types.

This pull request defines a filer interface which is implemented by all currently supported net listeners. It also two internally defined listener types to implement this interface.

Aside from being a cute way to use Go's type system, this makes it possible for external packages to pass in custom net.Listener implementations as long as they have an appropriate File() method. As before, listeners which do not will experience failures when calling GetFile() on a GracefulListener.

Two possibilities I chose not to pursue because of their broader implications for the Manners interface:

  1. Make GracefulListener implement the filer interface itself by aliasing GetFile() as File().
  2. Make GracefulListener only accept net.Listeners which also implement filer (probably by making the filer interface an explicit superset of net.Listener).

@pquerna
Copy link

pquerna commented Jan 4, 2016

LGTM

@horkhe horkhe force-pushed the master branch 2 times, most recently from 511292b to a585afd Compare October 4, 2016 19:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants