summaryrefslogtreecommitdiff
path: root/server.go
blob: 1562f5656bc61c065ca571b0d6e052718939533d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package sliderule

// 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
}