Skip to content

Commit

Permalink
Add badges and fix docs (#14)
Browse files Browse the repository at this point in the history
  • Loading branch information
destel authored Mar 26, 2024
1 parent 6b55a1c commit 05225c2
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Rill [![GoDoc](https://pkg.go.dev/badge/github.com/destel/rill)](https://pkg.go.dev/github.com/destel/rill)
# Rill [![GoDoc](https://pkg.go.dev/badge/github.com/destel/rill)](https://pkg.go.dev/github.com/destel/rill) [![Go Report Card](https://goreportcard.com/badge/github.com/destel/rill)](https://goreportcard.com/report/github.com/destel/rill) [![codecov](https://codecov.io/gh/destel/rill/graph/badge.svg?token=252K8OQ7E1)](https://codecov.io/gh/destel/rill)
Rill (noun: a small stream) is a comprehensive Go toolkit for streaming, parallel processing, and pipeline construction.
Designed to reduce boilerplate and simplify usage, it empowers developers to focus on core logic
without getting bogged down by the complexity of concurrency.
Expand Down Expand Up @@ -40,7 +40,7 @@ type KV struct {

func printValuesFromDB(ctx context.Context, urls []string) error {
ctx, cancel := context.WithCancel(ctx)
defer cancel() // In case of error, this ensures all http and redis operations are canceled
defer cancel() // In case of error, this ensures all http and DB operations are canceled

// Convert urls into a channel
urlsChan := rill.FromSlice(urls, nil)
Expand All @@ -58,7 +58,7 @@ func printValuesFromDB(ctx context.Context, urls []string) error {
// Organize keys into manageable batches of 10 for bulk operations
keyBatches := rill.Batch(keys, 10, 1*time.Second)

// Fetch values from Redis for each batch of keys
// Fetch values from DB for each batch of keys
resultBatches := rill.Map(keyBatches, 5, func(keys []string) ([]KV, error) {
values, err := dbMultiGet(ctx, keys...)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion batch.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ func Batch[A any](in <-chan Try[A], n int, timeout time.Duration) <-chan Try[[]A
return FromChans(batches, errs)
}

// Unbatch is the inverse of Batch. It takes a channel of batches and emits individual items.
// Unbatch is the inverse of [Batch]. It takes a channel of batches and emits individual items.
func Unbatch[A any](in <-chan Try[[]A]) <-chan Try[A] {
batches, errs := ToChans(in)
values := core.Unbatch(batches)
Expand Down
2 changes: 1 addition & 1 deletion core.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func OrderedFilter[A any](in <-chan Try[A], n int, f func(A) (bool, error)) <-ch
}

// FlatMap applies a function to each item in an input channel, where the function returns a channel of items.
// These items are then flattened into a single output channel. Uses n goroutines for concurrency.
// These items are then flattened into a single output channel using n goroutines for concurrency.
// The output order is not guaranteed: results are written to the output as soon as they're ready.
// Use [OrderedFlatMap] to preserve the input order.
func FlatMap[A, B any](in <-chan Try[A], n int, f func(A) <-chan Try[B]) <-chan Try[B] {
Expand Down
4 changes: 2 additions & 2 deletions examples/kv-read/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func main() {
// The pipeline leverages concurrency for fetching and processing and uses batching to reduce the number of db calls.
func printValuesFromDB(ctx context.Context, urls []string) error {
ctx, cancel := context.WithCancel(ctx)
defer cancel() // In case of error, this ensures all http and redis operations are canceled
defer cancel() // In case of error, this ensures all http and DB operations are canceled

// Convert urls into a channel
urlsChan := rill.FromSlice(urls, nil)
Expand All @@ -54,7 +54,7 @@ func printValuesFromDB(ctx context.Context, urls []string) error {
// Organize keys into manageable batches of 10 for bulk operations
keyBatches := rill.Batch(keys, 10, 1*time.Second)

// Fetch values from Redis for each batch of keys
// Fetch values from DB for each batch of keys
resultBatches := rill.Map(keyBatches, 5, func(keys []string) ([]KV, error) {
values, err := dbMultiGet(ctx, keys...)
if err != nil {
Expand Down

0 comments on commit 05225c2

Please sign in to comment.