forked from TrueCloudLab/frostfs-node
[#371] ir: Add morph cache metrics
Signed-off-by: Airat Arifullin a.arifullin@yadro.com
This commit is contained in:
parent
4f83ab0fb4
commit
90e9247b69
11 changed files with 154 additions and 27 deletions
|
@ -7,6 +7,7 @@ import (
|
|||
"time"
|
||||
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-node/internal/logs"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/metrics"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/util/logger"
|
||||
lru "github.com/hashicorp/golang-lru/v2"
|
||||
"github.com/nspcc-dev/neo-go/pkg/core/transaction"
|
||||
|
@ -42,6 +43,8 @@ type cfg struct {
|
|||
inactiveModeCb Callback
|
||||
|
||||
switchInterval time.Duration
|
||||
|
||||
morphCacheMetrics metrics.MorphCacheMetrics
|
||||
}
|
||||
|
||||
const (
|
||||
|
@ -104,7 +107,7 @@ func New(ctx context.Context, key *keys.PrivateKey, opts ...Option) (*Client, er
|
|||
}
|
||||
|
||||
cli := &Client{
|
||||
cache: newClientCache(),
|
||||
cache: newClientCache(cfg.morphCacheMetrics),
|
||||
logger: cfg.logger,
|
||||
acc: acc,
|
||||
accAddr: accAddr,
|
||||
|
@ -195,10 +198,11 @@ func newActor(ws *rpcclient.WSClient, acc *wallet.Account, cfg cfg) (*actor.Acto
|
|||
}})
|
||||
}
|
||||
|
||||
func newClientCache() cache {
|
||||
func newClientCache(morphCacheMetrics metrics.MorphCacheMetrics) cache {
|
||||
c, _ := lru.New[util.Uint256, uint32](100) // returns error only if size is negative
|
||||
return cache{
|
||||
txHeights: c,
|
||||
metrics: morphCacheMetrics,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -282,3 +286,9 @@ func WithSwitchInterval(i time.Duration) Option {
|
|||
c.switchInterval = i
|
||||
}
|
||||
}
|
||||
|
||||
func WithMorphCacheMetrics(morphCacheMetrics metrics.MorphCacheMetrics) Option {
|
||||
return func(c *cfg) {
|
||||
c.morphCacheMetrics = morphCacheMetrics
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue