forked from pallavidn/monitoring
-
Notifications
You must be signed in to change notification settings - Fork 0
/
simple_repo_entity.go
47 lines (38 loc) · 1.47 KB
/
simple_repo_entity.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package simpleRepo
import (
"github.com/turbonomic/turbo-go-monitoring/pkg/model"
"github.com/turbonomic/turbo-go-monitoring/pkg/repository"
)
// SimpleMetricRepoEntity is a simple implementation of the RepositoryEntity
type SimpleMetricRepoEntity struct {
entityType model.EntityType
entityId model.EntityId
metricMap repository.EntityMetricMap
}
func NewSimpleMetricRepoEntity(
entityType model.EntityType,
entityId model.EntityId,
) repository.RepositoryEntity {
return SimpleMetricRepoEntity{entityId: entityId, entityType: entityType, metricMap: make(repository.EntityMetricMap)}
}
func (repoEntity SimpleMetricRepoEntity) GetId() model.EntityId {
return repoEntity.entityId
}
func (repoEntity SimpleMetricRepoEntity) GetType() model.EntityType {
return repoEntity.entityType
}
func (repoEntity SimpleMetricRepoEntity) GetTypedId() model.EntityTypedId {
return model.EntityTypedId{EntityType: repoEntity.entityType, EntityId: repoEntity.entityId}
}
func (repoEntity SimpleMetricRepoEntity) GetAllMetrics() repository.EntityMetricMap {
return repoEntity.metricMap
}
func (repoEntity SimpleMetricRepoEntity) GetMetricValue(metricKey repository.EntityMetricKey) (model.MetricValue, error) {
return repoEntity.metricMap.GetMetricValue(metricKey.ResourceType, metricKey.PropType)
}
func (repoEntity SimpleMetricRepoEntity) SetMetricValue(
key repository.EntityMetricKey,
value model.MetricValue,
) {
repoEntity.metricMap.SetMetricValue(key.ResourceType, key.PropType, value)
}