/
meta.go
38 lines (29 loc) · 909 Bytes
/
meta.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
package evaluator
import (
"time"
"github.com/viant/gmetric"
"golang.org/x/sync/semaphore"
)
type EvaluatorMeta struct {
id string // model ID
// prevents potentially explosive thread generation due to concurrent requests
// this should be shared across all Evaluators.
semaphore *semaphore.Weighted
// prevents excessive waiting if semaphore is full and no other safeguards in place
maxEvaluatorWait time.Duration
semaMetric *gmetric.Operation
tfMetric *gmetric.Operation
}
func (e EvaluatorMeta) TFMetric() *gmetric.Operation {
return e.tfMetric
}
func MakeEvaluatorMeta(id string, semaphore *semaphore.Weighted, maxEvaluatorWait time.Duration,
semaMetric, tfMetric *gmetric.Operation) EvaluatorMeta {
return EvaluatorMeta{
id: id,
semaphore: semaphore,
maxEvaluatorWait: maxEvaluatorWait,
semaMetric: semaMetric,
tfMetric: tfMetric,
}
}