-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(BRIDGE-122): added relevant fake server methods to mock observab…
…ility service
- Loading branch information
1 parent
7a61908
commit 7109637
Showing
5 changed files
with
69 additions
and
11 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package backend | ||
|
||
import ( | ||
"time" | ||
|
||
"github.com/ProtonMail/go-proton-api" | ||
) | ||
|
||
type ObservabilityStatistics struct { | ||
Metrics []proton.ObservabilityMetric | ||
RequestTime []time.Time | ||
} | ||
|
||
func NewObservabilityStatistics() ObservabilityStatistics { | ||
return ObservabilityStatistics{ | ||
Metrics: make([]proton.ObservabilityMetric, 0), | ||
RequestTime: make([]time.Time, 0), | ||
} | ||
} | ||
|
||
func (b *Backend) PushObservabilityMetrics(metrics []proton.ObservabilityMetric) { | ||
writeBackend(b, func(b *unsafeBackend) { | ||
b.observabilityStatistics.Metrics = append(b.observabilityStatistics.Metrics, metrics...) | ||
b.observabilityStatistics.RequestTime = append(b.observabilityStatistics.RequestTime, time.Now()) | ||
}) | ||
} | ||
|
||
func (b *Backend) GetObservabilityStatistics() ObservabilityStatistics { | ||
return readBackendRet(b, func(b *unsafeBackend) ObservabilityStatistics { | ||
return b.observabilityStatistics | ||
}) | ||
} |
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