-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.go
93 lines (80 loc) · 1.84 KB
/
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
package service
import (
"context"
"fmt"
"net/http"
"github.com/gorilla/mux"
"github.com/grpc-ecosystem/grpc-gateway/v2/runtime"
"github.com/omecodes/libome"
"google.golang.org/grpc"
)
type WireEndpointFunc func(ctx context.Context, serveMux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) error
type PublicNodeGatewayParams struct {
ServiceName string
TargetNodeName string
NodeName string
ServiceType uint32
ServiceID string
Email string
Binder WireEndpointFunc
MuxWrapper MuxWrapper
Meta MD
}
type NodeGatewayParams struct {
ServiceName string
TargetNodeName string
NodeName string
ServiceType uint32
ServiceID string
Security ome.Security
Binder WireEndpointFunc
MuxWrapper MuxWrapper
Meta MD
}
type HTTPServerParams struct {
MiddlewareList []mux.MiddlewareFunc
ProvideRouter func() *mux.Router
Security ome.Security
ServiceType uint32
ServiceID string
Name string
Meta MD
}
type HTTPGatewayParams struct {
Email string
MiddlewareList []mux.MiddlewareFunc
ProvideRouter func() *mux.Router
ServiceType uint32
ServiceID string
Name string
Meta MD
}
type NodeParams struct {
RegisterHandlerFunc func(*grpc.Server)
ServiceType uint32
ServiceID string
Name string
Meta MD
}
type gPRCNode struct {
Name string
Secure bool
ServiceID string
Address string
Server *grpc.Server
}
func (s *gPRCNode) Stop() {
s.Server.Stop()
}
type httpNode struct {
Name string
Scheme string
Address string
Server *http.Server
}
func (g *httpNode) URL() string {
return fmt.Sprintf("%s://%s", g.Scheme, g.Address)
}
func (g *httpNode) Stop() error {
return g.Server.Shutdown(context.Background())
}