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

Function newDownstream

pkg/devspace/sync/downstream.go:39–78  ·  view source on GitHub ↗

newDownstream creates a new downstream handler with the given parameters

(reader io.ReadCloser, writer io.WriteCloser, sync *Sync)

Source from the content-addressed store, hash-verified

37
38// newDownstream creates a new downstream handler with the given parameters
39func newDownstream(reader io.ReadCloser, writer io.WriteCloser, sync *Sync) (*downstream, error) {
40 var (
41 clientReader io.Reader = reader
42 clientWriter io.Writer = writer
43 )
44
45 // Apply limits if specified
46 if sync.Options.DownstreamLimit > 0 {
47 limitedReader := shapeio.NewReader(reader)
48 limitedReader.SetRateLimit(float64(sync.Options.DownstreamLimit))
49 clientReader = limitedReader
50 }
51 if sync.Options.UpstreamLimit > 0 {
52 limitedWriter := shapeio.NewWriter(writer)
53 limitedWriter.SetRateLimit(float64(sync.Options.UpstreamLimit))
54 clientWriter = limitedWriter
55 }
56
57 // Create client connection
58 conn, err := util.NewClientConnection(clientReader, clientWriter)
59 if err != nil {
60 return nil, errors.Wrap(err, "new client connection")
61 }
62
63 // Create download exclude paths
64 ignoreMatcher, err := ignoreparser.CompilePaths(sync.Options.DownloadExcludePaths, sync.log)
65 if err != nil {
66 return nil, errors.Wrap(err, "compile paths")
67 }
68
69 return &downstream{
70 sync: sync,
71 reader: reader,
72 writer: writer,
73 client: remote.NewDownstreamClient(conn),
74 ignoreMatcher: ignoreMatcher,
75 unarchiver: NewUnarchiver(sync, false, sync.log),
76 conn: conn,
77 }, nil
78}
79
80func (d *downstream) populateFileMap() error {
81 d.sync.fileIndex.fileMapMutex.Lock()

Callers 1

InitDownstreamMethod · 0.85

Calls 4

NewClientConnectionFunction · 0.92
CompilePathsFunction · 0.92
NewDownstreamClientFunction · 0.92
NewUnarchiverFunction · 0.85

Tested by

no test coverage detected