-
Notifications
You must be signed in to change notification settings - Fork 163
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: reorganize the extension package (#155)
- Loading branch information
Showing
7 changed files
with
43 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
fs | ||
file | ||
out.txt |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package extension | ||
|
||
import "github.com/reugn/go-streams" | ||
|
||
// IgnoreSink represents a simple outbound connector that discards | ||
// all elements of a stream. | ||
type IgnoreSink struct { | ||
in chan any | ||
} | ||
|
||
var _ streams.Sink = (*IgnoreSink)(nil) | ||
|
||
// NewIgnoreSink returns a new IgnoreSink connector. | ||
func NewIgnoreSink() *IgnoreSink { | ||
ignoreSink := &IgnoreSink{ | ||
in: make(chan any), | ||
} | ||
|
||
// asynchronously process stream data | ||
go ignoreSink.process() | ||
|
||
return ignoreSink | ||
} | ||
|
||
func (ignore *IgnoreSink) process() { | ||
for { | ||
_, ok := <-ignore.in | ||
if !ok { | ||
break | ||
} | ||
} | ||
} | ||
|
||
// In returns the input channel of the IgnoreSink connector. | ||
func (ignore *IgnoreSink) In() chan<- any { | ||
return ignore.in | ||
} | ||
|
||
// AwaitCompletion is a no-op for the IgnoreSink. | ||
func (ignore *IgnoreSink) AwaitCompletion() { | ||
// no-op | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters