MCPcopy Index your code
hub / github.com/FunctionStream/function-stream / NewSourceTube

Method NewSourceTube

fs/contube/memory.go:80–115  ·  view source on GitHub ↗
(ctx context.Context, configMap ConfigMap)

Source from the content-addressed store, hash-verified

78}
79
80func (f *MemoryQueueFactory) NewSourceTube(ctx context.Context, configMap ConfigMap) (<-chan Record, error) {
81 config := SourceQueueConfig{}
82 if err := configMap.ToConfigStruct(&config); err != nil {
83 return nil, err
84 }
85 result := make(chan Record)
86
87 var wg sync.WaitGroup
88 for _, topic := range config.Topics {
89 t := topic
90 wg.Add(1)
91 go func() {
92 <-ctx.Done()
93 f.release(t)
94 }()
95 c := f.getOrCreateChan(t)
96 go func() {
97 defer wg.Done()
98 for {
99 select {
100 case <-ctx.Done():
101 return
102 case event := <-c:
103 result <- event
104 }
105 }
106 }()
107 }
108
109 go func() {
110 wg.Wait()
111 close(result)
112 }()
113
114 return result, nil
115}
116
117func (f *MemoryQueueFactory) NewSinkTube(ctx context.Context, configMap ConfigMap) (chan<- Record, error) {
118 config := SinkQueueConfig{}

Callers

nothing calls this directly

Calls 3

releaseMethod · 0.95
getOrCreateChanMethod · 0.95
ToConfigStructMethod · 0.80

Tested by

no test coverage detected