Documentation ¶
Overview ¶
Copyright © 2020 Marvin
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright © 2020 Marvin ¶
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Index ¶
Constants ¶
const ( DefaultThreadErrorMaxRetries = 3 DefaultThreadErrorRereyDelay = 300 * time.Millisecond )
Variables ¶
This section is empty.
Functions ¶
func Retry ¶
func Retry(config *RetryConfig, shouldRetry ShouldRetry, fn func() error) (err error)
Types ¶
type Group ¶
type Group struct { ResultC chan Result // contains filtered or unexported fields }
A Group is reference to errgroup package
func (*Group) Go ¶
Go calls the given function in a new goroutine. It blocks until the new goroutine can be added without the number of active goroutines in the group exceeding the configured limit.
The first call to return a non-nil error cancels the group's context, if the group was created by calling WithContext. The error will be returned by Wait.
func (*Group) SetLimit ¶
SetLimit limits the number of active goroutines in this group to at most n. A negative value indicates no limit.
Any subsequent call to the Go method will block until it can add an active goroutine without exceeding the configured limit.
The limit must not be modified while any goroutines in the group are active.
type RetryConfig ¶
type ShouldRetry ¶
ShouldRetry determines whether a retry is needed
shouldRetry := func(err error) bool { return errors.Is(err, ErrTemporaryFailure) }