Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Retry Observable FromChannel #326

Open
aibolorazbekov opened this issue Sep 2, 2021 · 0 comments
Open

Retry Observable FromChannel #326

aibolorazbekov opened this issue Sep 2, 2021 · 0 comments
Assignees

Comments

@aibolorazbekov
Copy link

Hi All.

I'm trying to call Retry for Observable that returned FromChannel.
I want make retry 10 times, but it did it only one time.

I tried an example from documentation (Observable from Just operation) - making retry 10 times - and it did it 10 times.

Here is the code that i'm working:


pipeline := asObservable(streamCh)
<-pipeline.
	Map(func(c context.Context, i interface{}) (interface{}, error) {
		return nil, errors.New("foo")
	}). // here i want to make retry 10 times if error foo returned 
	Retry(10, func(e error) bool {
		return e.Error() == "foo"
	})
	Run(rxgo.WithErrorStrategy(errorStrategy))

func asObservable(streamCh chan rxgo.Item) rxgo.Observable {
	go func() {
		for {
			select {
			case msg := <-o.msgs:
				streamCh <- rxgo.Of(msg)
			}
		}
	}()

	return rxgo.FromChannel(o.streamCh)
}

So, it seems like, i there is something that i don't understand mechanics of Observable that returned FromChannel...

Can someone please, help me to solve the issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants