-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
144 additions
and
35 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
29 changes: 29 additions & 0 deletions
29
orchard-core/src/main/scala/com/salesforce/mce/orchard/util/FixedDelay.scala
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,29 @@ | ||
/* | ||
* Copyright (c) 2022, salesforce.com, inc. | ||
* All rights reserved. | ||
* SPDX-License-Identifier: BSD-3-Clause | ||
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause | ||
*/ | ||
|
||
package com.salesforce.mce.orchard.util | ||
|
||
import scala.concurrent.duration | ||
import scala.concurrent.duration.FiniteDuration | ||
|
||
trait FixedDelay extends Policy { | ||
|
||
def fixedDelay: FiniteDuration = FixedDelay.defaultFixedDelay | ||
|
||
def delay(): FiniteDuration = FiniteDuration(fixedDelay.toSeconds, duration.SECONDS) | ||
|
||
} | ||
|
||
object FixedDelay { | ||
|
||
val defaultFixedDelay: FiniteDuration = FiniteDuration(10, duration.SECONDS) | ||
|
||
def apply(fixedDelayValue: FiniteDuration = defaultFixedDelay) = new FixedDelay { | ||
override def fixedDelay = fixedDelayValue | ||
|
||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
orchard-core/src/main/scala/com/salesforce/mce/orchard/util/JitteredDelay.scala
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,41 @@ | ||
/* | ||
* Copyright (c) 2022, salesforce.com, inc. | ||
* All rights reserved. | ||
* SPDX-License-Identifier: BSD-3-Clause | ||
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause | ||
*/ | ||
|
||
package com.salesforce.mce.orchard.util | ||
|
||
import scala.concurrent.duration | ||
import scala.concurrent.duration.FiniteDuration | ||
import scala.util.Random | ||
|
||
trait JitteredDelay extends Policy { | ||
|
||
def minDelay: FiniteDuration = JitteredDelay.defaultMinDelay | ||
|
||
def maxDelay: FiniteDuration = JitteredDelay.defaultMaxDelay | ||
|
||
def delay(): FiniteDuration = { | ||
val rand = new Random() | ||
FiniteDuration(rand.between(minDelay.toSeconds, maxDelay.toSeconds + 1L), duration.SECONDS) | ||
} | ||
} | ||
|
||
object JitteredDelay { | ||
|
||
val defaultMinDelay: FiniteDuration = FiniteDuration(10, duration.SECONDS) | ||
|
||
val defaultMaxDelay: FiniteDuration = FiniteDuration(20, duration.SECONDS) | ||
|
||
def apply( | ||
minDelayValue: FiniteDuration = defaultMinDelay, | ||
maxDelayValue: FiniteDuration = defaultMaxDelay | ||
) = | ||
new JitteredDelay { | ||
override def minDelay: FiniteDuration = minDelayValue | ||
|
||
override def maxDelay: FiniteDuration = maxDelayValue | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
orchard-core/src/main/scala/com/salesforce/mce/orchard/util/Policy.scala
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,19 @@ | ||
/* | ||
* Copyright (c) 2022, salesforce.com, inc. | ||
* All rights reserved. | ||
* SPDX-License-Identifier: BSD-3-Clause | ||
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause | ||
*/ | ||
|
||
package com.salesforce.mce.orchard.util | ||
|
||
import scala.concurrent.duration.FiniteDuration | ||
|
||
trait Policy { | ||
|
||
/** | ||
* @return the number of seconds to wait for the next attempt | ||
*/ | ||
def delay(): FiniteDuration | ||
|
||
} |
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 |
---|---|---|
@@ -1 +1 @@ | ||
ThisBuild / version := "0.22.2" | ||
ThisBuild / version := "0.23.0" |