Skip to content

Commit

Permalink
success -> healthy
Browse files Browse the repository at this point in the history
  • Loading branch information
juliangruber committed Oct 4, 2023
1 parent e2fd10b commit 8a18435
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
18 changes: 9 additions & 9 deletions lib/activity-state.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
/* global Zinnia */

// Create activity events when we go online or offline
// Create activity events when we become healthy or produce errors
export class ActivityState {
#ok = null
#healthy = null

onOutdatedClient () {
this.onError('SPARK is outdated. Please upgrade Filecoin Station to the latest version.')
}

onError (msg) {
if (this.#ok === null || this.#ok) {
this.#ok = false
if (this.#healthy === null || this.#healthy) {
this.#healthy = false
Zinnia.activity.error(msg ?? 'SPARK failed reporting retrieval')
}
}

onSuccess () {
if (this.#ok === null) {
this.#ok = true
onHealthy () {
if (this.#healthy === null) {
this.#healthy = true
Zinnia.activity.info('SPARK started reporting retrievals')
} else if (!this.#ok) {
this.#ok = true
} else if (!this.#healthy) {
this.#healthy = true
Zinnia.activity.info('SPARK retrieval reporting resumed')
}
}
Expand Down
2 changes: 1 addition & 1 deletion lib/spark.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ export default class Spark {
while (true) {
try {
await this.nextRetrieval()
this.#activity.onSuccess()
this.#activity.onHealthy()
} catch (err) {
if (err.statusCode === 400 && err.serverMessage === 'OUTDATED CLIENT') {
this.#activity.onOutdatedClient()
Expand Down

0 comments on commit 8a18435

Please sign in to comment.