-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* log test results (#608) * add health check to stellar observer (#602) * stellar observer retry with exponential back-off timer (#607) * update helm chart by exposing the metrics port to the internal network (#610) * expose the `8082` metrics port to the internal network. * add `deployment.annotations` to the example values. * delete duplicate appearance of `ORG_URL` in the example values. * updated the version string and the change log * allow refund status to patch transaction (#618) * fix: stop crashing when parsing response content into ErrorResponse (#612) * separate observer deployment (#613) * remove basic tests from release_main.yml, release_release.yml to avoid duplicating tests
- Loading branch information
Showing
34 changed files
with
596 additions
and
85 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
14 changes: 14 additions & 0 deletions
14
api-schema/src/main/java/org/stellar/anchor/api/exception/EventPublishException.java
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 org.stellar.anchor.api.exception; | ||
|
||
import lombok.EqualsAndHashCode; | ||
|
||
@EqualsAndHashCode(callSuper = false) | ||
public class EventPublishException extends AnchorException { | ||
public EventPublishException(String message, Exception cause) { | ||
super(message, cause); | ||
} | ||
|
||
public EventPublishException(String message) { | ||
super(message); | ||
} | ||
} |
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
3 changes: 2 additions & 1 deletion
3
core/src/main/java/org/stellar/anchor/event/EventPublishService.java
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,7 +1,8 @@ | ||
package org.stellar.anchor.event; | ||
|
||
import org.stellar.anchor.api.exception.EventPublishException; | ||
import org.stellar.anchor.event.models.AnchorEvent; | ||
|
||
public interface EventPublishService { | ||
void publish(AnchorEvent event); | ||
void publish(AnchorEvent event) throws EventPublishException; | ||
} |
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
45 changes: 45 additions & 0 deletions
45
core/src/main/java/org/stellar/anchor/util/ExponentialBackoffTimer.java
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,45 @@ | ||
package org.stellar.anchor.util; | ||
|
||
/** | ||
* ExponentialBackoffUtil is used to do an exponential back-off, where the sleep time is doubled | ||
* every time, until things succeed and the `resetSleepSeconds()` method is called. | ||
*/ | ||
public class ExponentialBackoffTimer { | ||
static final long DEFAULT_INITIAL_SLEEP_SECONDS = 1; | ||
static final long DEFAULT_MAX_SLEEP_SECONDS = 300; // 5 minutes | ||
|
||
final long initialSleepSeconds; | ||
final long maxSleepSeconds; | ||
long sleepSeconds; | ||
|
||
public ExponentialBackoffTimer() { | ||
this(DEFAULT_INITIAL_SLEEP_SECONDS, DEFAULT_MAX_SLEEP_SECONDS); | ||
} | ||
|
||
public ExponentialBackoffTimer(long initialSleepSeconds, long maxSleepSeconds) { | ||
if (initialSleepSeconds < 1) { | ||
throw new IllegalArgumentException( | ||
"The formula 'initialSleepSeconds >= 1' is not being respected."); | ||
} | ||
this.initialSleepSeconds = initialSleepSeconds; | ||
this.sleepSeconds = initialSleepSeconds; | ||
|
||
if (maxSleepSeconds < initialSleepSeconds) { | ||
throw new IllegalArgumentException( | ||
"The formula 'maxSleepSeconds >= initialSleepSeconds' is not being respected."); | ||
} | ||
this.maxSleepSeconds = maxSleepSeconds; | ||
} | ||
|
||
public void increase() { | ||
sleepSeconds = Long.min(sleepSeconds * 2, maxSleepSeconds); | ||
} | ||
|
||
public void reset() { | ||
sleepSeconds = initialSleepSeconds; | ||
} | ||
|
||
public void sleep() throws InterruptedException { | ||
Thread.sleep(sleepSeconds * 1000); | ||
} | ||
} |
80 changes: 80 additions & 0 deletions
80
core/src/test/kotlin/org/stellar/anchor/util/ExponentialBackoffTimerTest.kt
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,80 @@ | ||
package org.stellar.anchor.util | ||
|
||
import java.time.Instant | ||
import java.time.temporal.ChronoUnit | ||
import kotlin.test.assertEquals | ||
import org.junit.jupiter.api.Assertions.* | ||
import org.junit.jupiter.api.Test | ||
import org.junit.jupiter.api.assertThrows | ||
|
||
internal class ExponentialBackoffTimerTest { | ||
@Test | ||
fun test_constructorWithParameters() { | ||
// validate if 'initialSleepSeconds >= 1' | ||
var ex: IllegalArgumentException = assertThrows { ExponentialBackoffTimer(0, 0) } | ||
assertEquals("The formula 'initialSleepSeconds >= 1' is not being respected.", ex.message) | ||
|
||
// validate if 'maxSleepSeconds >= initialSleepSeconds' | ||
ex = assertThrows { ExponentialBackoffTimer(1, 0) } | ||
assertEquals( | ||
"The formula 'maxSleepSeconds >= initialSleepSeconds' is not being respected.", | ||
ex.message | ||
) | ||
|
||
// constructor with all parameters works | ||
lateinit var exponentialBackoffTimer: ExponentialBackoffTimer | ||
assertDoesNotThrow { exponentialBackoffTimer = ExponentialBackoffTimer(1, 2) } | ||
assertEquals(1, exponentialBackoffTimer.initialSleepSeconds) | ||
assertEquals(2, exponentialBackoffTimer.maxSleepSeconds) | ||
|
||
// constructor with no parameters works | ||
assertDoesNotThrow { exponentialBackoffTimer = ExponentialBackoffTimer() } | ||
assertEquals( | ||
ExponentialBackoffTimer.DEFAULT_INITIAL_SLEEP_SECONDS, | ||
exponentialBackoffTimer.initialSleepSeconds | ||
) | ||
assertEquals( | ||
ExponentialBackoffTimer.DEFAULT_MAX_SLEEP_SECONDS, | ||
exponentialBackoffTimer.maxSleepSeconds | ||
) | ||
} | ||
|
||
@Test | ||
fun test_increase() { | ||
val exponentialBackoffTimer = ExponentialBackoffTimer(1, 5) | ||
assertEquals(1, exponentialBackoffTimer.sleepSeconds) | ||
|
||
exponentialBackoffTimer.increase() | ||
assertEquals(2, exponentialBackoffTimer.sleepSeconds) | ||
|
||
exponentialBackoffTimer.increase() | ||
assertEquals(4, exponentialBackoffTimer.sleepSeconds) | ||
|
||
exponentialBackoffTimer.increase() | ||
assertEquals(5, exponentialBackoffTimer.sleepSeconds) | ||
|
||
exponentialBackoffTimer.increase() | ||
assertEquals(5, exponentialBackoffTimer.sleepSeconds) | ||
} | ||
|
||
@Test | ||
fun test_reset() { | ||
val exponentialBackoffTimer = ExponentialBackoffTimer(1, 5) | ||
exponentialBackoffTimer.increase() | ||
assertEquals(2, exponentialBackoffTimer.sleepSeconds) | ||
|
||
exponentialBackoffTimer.reset() | ||
assertEquals(1, exponentialBackoffTimer.sleepSeconds) | ||
} | ||
|
||
@Test | ||
fun test_sleep() { | ||
val exponentialBackoffTimer = ExponentialBackoffTimer(1, 5) | ||
|
||
val beforeSleep = Instant.now() | ||
exponentialBackoffTimer.sleep() | ||
val afterSleep = Instant.now() | ||
|
||
assertEquals(1, ChronoUnit.SECONDS.between(beforeSleep, afterSleep)) | ||
} | ||
} |
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 |
---|---|---|
|
@@ -21,13 +21,10 @@ deployment: | |
configMaps: | ||
- name: assets | ||
mountPath: assets | ||
hosts: | ||
- host: "your_anchor_domain.com" | ||
path: / | ||
pathType: Prefix | ||
backend: | ||
servicePort: "{{ .Values.service.containerPort }}" | ||
serviceName: "{{ .Values.fullName }}-svc-{{ .Values.service.name }}" | ||
annotations: | ||
prometheus.io/path: /actuator/prometheus | ||
prometheus.io/port: "8082" | ||
prometheus.io/scrape: "true" | ||
env: | ||
- name: STELLAR_ANCHOR_CONFIG | ||
value: file:/config/anchor-config.yaml | ||
|
@@ -58,6 +55,35 @@ ingress: | |
backend: | ||
servicePort: "{{ .Values.service.containerPort }}" | ||
serviceName: "{{ .Values.fullName }}-svc-{{ .Values.service.name }}" | ||
# | ||
# If you want to have a dedicated stellar-observer service, you need to | ||
# uncomment the `stellarObserver` section below. | ||
# | ||
# Attention! If you use the stellar observer as a separate service – by setting | ||
# `stellarObserver.enabled` flag to `true` – you must use a shared database that | ||
# will be accessible by both deployments (sep-server and stellar-observer). | ||
# In-memory databases won't work. | ||
# stellarObserver: | ||
# # This will enable the stellar-observer service as a separate deployment: | ||
# enabled: true | ||
# # The stellarObserver.deployment section is optional, the templates have | ||
# # default values. | ||
# deployment: | ||
# port: 8083 | ||
# probePath: "/health" | ||
# probePeriodSeconds: 15 | ||
# initialDelaySeconds: 60 | ||
# startupProbeFailureThreshold: 10 | ||
# livenessProbeFailureThreshold: 2 | ||
# ingress: | ||
# tls: | ||
# host: "observer.your_anchor_domain.com" # Replace this with a valid host name | ||
# rules: | ||
# hosts: | ||
# - host: "observer.your_anchor_domain.com" # Replace this with a valid host name | ||
# path: / | ||
# pathType: Prefix | ||
# | ||
stellar: | ||
toml: | ||
#accounts: ['"GCHLHDBOKG2JWMJQBTLSL5XG6NO7ESXI2TAQKZXCXWXB5WI2X6W233PR"'] | ||
|
@@ -66,7 +92,6 @@ stellar: | |
ORG_NAME: "Stellar Development Foundation" | ||
ORG_URL: "https://www.stellar.org" | ||
ORG_DESCRIPTION: "Stellar Network" | ||
ORG_URL: "https://your_org_url.png" | ||
ORG_SUPPORT_EMAIL: "[email protected]" | ||
anchor: | ||
data_access: | ||
|
Oops, something went wrong.