diff options
author | tjpcc <tjp@ctrl-c.club> | 2023-08-12 09:40:39 -0600 |
---|---|---|
committer | tjpcc <tjp@ctrl-c.club> | 2023-08-12 09:40:39 -0600 |
commit | 23bc5f4fb7542e64c94eaa7fe2c7a6aa55010898 (patch) | |
tree | ec8113d3aa2379e3ca9cb3c6e13a5531895ea8c0 /internal/types/server.go | |
parent | 57a31a9b2cd549174d839b9b91b47db337f174cc (diff) |
move common types to an internal package
This helps avoid import cycles.
Diffstat (limited to 'internal/types/server.go')
-rw-r--r-- | internal/types/server.go | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/internal/types/server.go b/internal/types/server.go new file mode 100644 index 0000000..80d12b5 --- /dev/null +++ b/internal/types/server.go @@ -0,0 +1,42 @@ +package types + +// Server is a type which can serve a protocol. +type Server interface { + // Serve blocks listening for connections on an interface. + // + // It will only return after Close() has been called. + Serve() error + + // Close initiates a graceful shutdown of the server. + // + // It blocks until all resources have been cleaned up and all + // outstanding requests have been handled and responses sent. + Close() + + // Closed indicates whether Close has been called. + // + // It may be true even if the graceful shutdown procedure + // hasn't yet completed. + Closed() bool + + // Protocol returns the protocol being served by the server. + Protocol() string + + // Network returns the network type on which the server is running. + Network() string + + // Address returns the address on which the server is listening. + Address() string + + // Hostname returns just the hostname portion of the listen address. + Hostname() string + + // Port returns the port on which the server is listening. + // + // It will return the empty string if the network type does not + // have ports (unix sockets, for example). + Port() string + + // LogError sends a log message to the server's error log. + LogError(keyvals ...any) error +} |