/
types_server.go
55 lines (45 loc) · 1000 Bytes
/
types_server.go
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
43
44
45
46
47
48
49
50
51
52
53
54
55
package types
import (
"io"
"strings"
)
// EndpointType is a type of endpoint.
type EndpointType int
const (
// UnknownEndpointType is an unknown endpoint type.
UnknownEndpointType EndpointType = iota
// UnixEndpoint is a UNIX socket endpoint.
UnixEndpoint
// TCPEndpoint is a TCP endpoint.
TCPEndpoint
)
// String returns the endpoint type's string representation.
func (t EndpointType) String() string {
switch t {
case UnixEndpoint:
return "unix"
case TCPEndpoint:
return "tcp"
default:
return ""
}
}
// ParseEndpointType parses the endpoint type.
func ParseEndpointType(str string) EndpointType {
str = strings.ToLower(str)
switch str {
case "unix":
return UnixEndpoint
case "tcp":
return TCPEndpoint
}
return UnknownEndpointType
}
// Server is the interface for a libStorage server.
type Server interface {
io.Closer
// Name returns the name of the server.
Name() string
// Addrs returns the server's configured endpoint addresses.
Addrs() []string
}