MCPcopy Index your code
hub / github.com/devspace-sh/devspace / StartUpstreamServer

Function StartUpstreamServer

helper/server/upstream.go:42–75  ·  view source on GitHub ↗

StartUpstreamServer starts a new upstream server with the given reader and writer

(reader io.Reader, writer io.Writer, options *UpstreamOptions)

Source from the content-addressed store, hash-verified

40
41// StartUpstreamServer starts a new upstream server with the given reader and writer
42func StartUpstreamServer(reader io.Reader, writer io.Writer, options *UpstreamOptions) error {
43 pipe := util.NewStdStreamJoint(reader, writer, options.ExitOnClose)
44 lis := util.NewStdinListener()
45 done := make(chan error)
46
47 // Compile ignore paths
48 ignoreMatcher, err := ignoreparser.CompilePaths(options.ExludePaths, logpkg.Discard)
49 if err != nil {
50 return errors.Wrap(err, "compile paths")
51 }
52
53 go func() {
54 s := grpc.NewServer()
55 upstream := &Upstream{
56 options: options,
57 ignoreMatcher: ignoreMatcher,
58 ping: &pingtimeout.PingTimeout{},
59 }
60
61 if options.Ping {
62 doneChan := make(chan struct{})
63 defer close(doneChan)
64 upstream.ping.Start(doneChan)
65 }
66
67 remote.RegisterUpstreamServer(s, upstream)
68 reflection.Register(s)
69
70 done <- s.Serve(lis)
71 }()
72
73 lis.Ready(pipe)
74 return <-done
75}
76
77// Upstream is the implementation for the upstream server
78type Upstream struct {

Callers 4

TestInitialSyncFunction · 0.92
TestNormalSyncFunction · 0.92
RunMethod · 0.92
TestUpstreamServerFunction · 0.85

Calls 7

ReadyMethod · 0.95
NewStdStreamJointFunction · 0.92
NewStdinListenerFunction · 0.92
CompilePathsFunction · 0.92
RegisterUpstreamServerFunction · 0.92
closeFunction · 0.85
StartMethod · 0.65

Tested by 3

TestInitialSyncFunction · 0.74
TestNormalSyncFunction · 0.74
TestUpstreamServerFunction · 0.68