Skip to content

Commit

Permalink
Merge pull request #152 from ChristopherDavenport/addUnsafeConstructor
Browse files Browse the repository at this point in the history
Add Unsafe Constructor
  • Loading branch information
ChristopherDavenport authored Jan 6, 2021
2 parents df1b645 + ef575b5 commit 1428b99
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ tags

.bloop
.metals
project/metals.sbt
project/metals.sbt
.vscode
29 changes: 29 additions & 0 deletions core/src/main/scala/io/chrisdavenport/circuit/CircuitBreaker.scala
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,35 @@ object CircuitBreaker {
)
}

/**
* For Custom Ref Implementations
* Ideally this will be in some valid state for the state machine and that
* maxFailures/resetTimeout/exponentialBackoffFactor/maxResetTimeout will all be
* consistent across users or else you may wait based on incorrect information.
*
*/
def unsafe[G[_]: Sync: Clock](
ref: Ref[G, State],
maxFailures: Int,
resetTimeout: FiniteDuration,
exponentialBackoffFactor: Double,
maxResetTimeout: Duration,
onRejected: G[Unit],
onClosed: G[Unit],
onHalfOpen: G[Unit],
onOpen: G[Unit]
): CircuitBreaker[G] = new SyncCircuitBreaker[G](
ref,
maxFailures,
resetTimeout,
exponentialBackoffFactor,
maxResetTimeout,
onRejected,
onClosed,
onHalfOpen,
onOpen
)

/** Type-alias to document timestamps specified in milliseconds, as returned by
* Clock.realTime.
*/
Expand Down

0 comments on commit 1428b99

Please sign in to comment.