-
Notifications
You must be signed in to change notification settings - Fork 183
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add factory interface and implementations
- Loading branch information
Simon Lantinga
committed
Jun 10, 2020
1 parent
31cc31b
commit feb5bad
Showing
5 changed files
with
76 additions
and
0 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
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
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
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
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,14 @@ | ||
package backoff | ||
|
||
// A Factory creates and returns a new backoff policy | ||
type Factory interface { | ||
NewBackOff() BackOff | ||
} | ||
|
||
// FactoryFunc is a function that returns a new backoff policy | ||
type FactoryFunc func() BackOff | ||
|
||
// NewBackOff implements Factory, allowing a FactoryFunc to be passed to anyywhere that accepts a Factory | ||
func (ff FactoryFunc) NewBackOff() BackOff { | ||
return ff() | ||
} |