Skip to content
This repository was archived by the owner on May 6, 2024. It is now read-only.
This repository was archived by the owner on May 6, 2024. It is now read-only.

Use iterators instead of channels on Async methods. #38

Description

@ajnavarro

Instead of returning a channel for async methods, we should use iterators to avoid goroutines chains when using the API. We see a goroutine chain when we want to transform the channel type to another, needing a new channel and a new goroutine to process it.

Proposal

type Iterator struct {}
func (i *Iterator) Next()(AsyncReturn,error)
func (i *Iterator) HasNext() bool

Usage

for iter, err := o.getAsyncIterator(ctx,req); iter.HasNext(); {
    if err != nil {
        return err
    }

    value, err := iter.Next()
    if err != nil {
        return err
    }
    
    fmt.Println(value)
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions