-
Notifications
You must be signed in to change notification settings - Fork 2k
/
server.go
40 lines (34 loc) · 1.11 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
package docklog
import (
"golang.org/x/net/context"
plugin "github.com/hashicorp/go-plugin"
"github.com/hashicorp/nomad/drivers/docker/docklog/proto"
)
// dockerLoggerServer is the server side translation between the protobuf and native interfaces
type dockerLoggerServer struct {
broker *plugin.GRPCBroker
impl DockerLogger
}
// Start proxies the protobuf Start RPC to the Start fun of the DockerLogger interface
func (s *dockerLoggerServer) Start(ctx context.Context, req *proto.StartRequest) (*proto.StartResponse, error) {
opts := &StartOpts{
Endpoint: req.Endpoint,
ContainerID: req.ContainerId,
Stdout: req.StdoutFifo,
Stderr: req.StderrFifo,
TTY: req.Tty,
TLSCert: req.TlsCert,
TLSKey: req.TlsKey,
TLSCA: req.TlsCa,
}
err := s.impl.Start(opts)
if err != nil {
return nil, err
}
resp := &proto.StartResponse{}
return resp, nil
}
// Stop proxies the protobuf Stop RPC to the Stop fun of the DockerLogger interface
func (s *dockerLoggerServer) Stop(ctx context.Context, req *proto.StopRequest) (*proto.StopResponse, error) {
return &proto.StopResponse{}, s.impl.Stop()
}