Documentation
¶
Index ¶
- Constants
- Variables
- func CreateCacheCobraCommand() *cobra.Command
- func Server(ctx context.Context, listenAddr string, metricsAddr string, ...)
- type CacheMetrics
- type CacheServer
- type CacheValue
- type LastestCacheStore
- type RelayerCacheServer
- func (s *RelayerCacheServer) FlushCache(ctx context.Context, req *emptypb.Empty) (*emptypb.Empty, error)
- func (s *RelayerCacheServer) GetRelay(ctx context.Context, relayCacheGet *relaytypes.RelayCacheGet) (*relaytypes.CacheRelayReply, error)
- func (s *RelayerCacheServer) Health(ctx context.Context, req *emptypb.Empty) (*relaytypes.CacheUsage, error)
- func (s *RelayerCacheServer) PrintCacheStats(ctx context.Context, desc string)
- func (s *RelayerCacheServer) SetRelay(ctx context.Context, relayCacheSet *relaytypes.RelayCacheSet) (*emptypb.Empty, error)
Constants ¶
const ( FlagLogLevel = "log_level" FlagMetricsAddress = "metrics_address" )
const ( DbValueConfirmationAttempts = 5 SEP = ";" // CompressionThreshold is the minimum data size (in bytes) before gzip is attempted. CompressionThreshold = 1024 )
const ( ExpirationFlagName = "expiration" ExpirationTimeFinalizedMultiplierFlagName = "expiration-multiplier" ExpirationNonFinalizedFlagName = "expiration-non-finalized" ExpirationTimeNonFinalizedMultiplierFlagName = "expiration-non-finalized-multiplier" ExpirationBlocksHashesToHeightsFlagName = "expiration-blocks-hashes-to-heights" ExpirationNodeErrorsOnFinalizedFlagName = "expiration-finalized-node-errors" FlagCacheSizeName = "max-items" DefaultExpirationForNonFinalized = 500 * time.Millisecond DefaultExpirationTimeFinalizedMultiplier = 1.0 DefaultExpirationTimeNonFinalizedMultiplier = 1.0 DefaultExpirationBlocksHashesToHeights = 48 * time.Hour DefaultExpirationTimeFinalized = time.Hour DefaultExpirationNodeErrors = 250 * time.Millisecond CacheNumCounters = 100000000 // expect 10M items )
const (
DisabledFlagOption = "disabled"
)
Variables ¶
var ( NotFoundError = errors.New("cache entry for specific block and request wasn't found") HashMismatchError = errors.New("cache entry for specific block and request had a mismatching hash stored") EntryTypeError = errors.New("cache entry for specific block and request had a mismatching object stored") )
Functions ¶
func CreateCacheCobraCommand ¶
Types ¶
type CacheMetrics ¶
type CacheMetrics struct {
// contains filtered or unexported fields
}
func NewCacheMetricsServer ¶
func NewCacheMetricsServer(listenAddress string) *CacheMetrics
func (*CacheMetrics) AddApiSpecific ¶
func (c *CacheMetrics) AddApiSpecific(block int64, chainId string, hit bool)
func (*CacheMetrics) AddExpired ¶
func (c *CacheMetrics) AddExpired()
func (*CacheMetrics) SetCacheSize ¶
func (c *CacheMetrics) SetCacheSize(size int64)
type CacheServer ¶
type CacheServer struct {
ExpirationFinalized time.Duration
ExpirationNonFinalized time.Duration
ExpirationNodeErrors time.Duration
ExpirationBlocksHashesToHeights time.Duration
CacheMetrics *CacheMetrics
CacheMaxCost int64
// contains filtered or unexported fields
}
func (*CacheServer) ExpirationForChain ¶
func (cs *CacheServer) ExpirationForChain(averageBlockTimeForChain time.Duration) time.Duration
func (*CacheServer) GetTotalCacheSize ¶
func (cs *CacheServer) GetTotalCacheSize() int64
func (*CacheServer) InitCache ¶
func (cs *CacheServer) InitCache( ctx context.Context, expiration time.Duration, expirationNonFinalized time.Duration, expirationNodeErrorsOnFinalized time.Duration, expirationBlocksHashesToHeights time.Duration, metricsAddr string, expirationFinalizedMultiplier float64, expirationNonFinalizedMultiplier float64, )
type CacheValue ¶
type CacheValue struct {
Response relaytypes.RelayReply
Hash []byte
OptionalMetadata []relaytypes.Metadata
SeenBlock int64
IsCompressed bool
}
func (*CacheValue) Cost ¶
func (cv *CacheValue) Cost() int64
func (*CacheValue) ToCacheReply ¶
func (cv *CacheValue) ToCacheReply() *relaytypes.CacheRelayReply
type LastestCacheStore ¶
type LastestCacheStore struct {
// contains filtered or unexported fields
}
func (*LastestCacheStore) Cost ¶
func (cv *LastestCacheStore) Cost() int64
type RelayerCacheServer ¶
type RelayerCacheServer struct {
relaytypes.UnimplementedRelayerCacheServer
CacheServer *CacheServer
// contains filtered or unexported fields
}
func (*RelayerCacheServer) FlushCache ¶
func (s *RelayerCacheServer) FlushCache(ctx context.Context, req *emptypb.Empty) (*emptypb.Empty, error)
FlushCache empties every Ristretto store on this cache server. Reached only from the smart router's /debug/reset-all handler so black-box tests can drop stale entries without restarting the pod. Ristretto's Clear() is not atomic and assumes no concurrent Set/Get; Wait() drains the asynchronous Set buffer so a Set in flight at Clear time can't survive the flush and serve a hit on the next Get. Caveat: this guarantee only holds when the test framework stops issuing relay traffic before calling /debug/reset-all — a concurrent Set buffered during the Clear/Wait window can still resurface as a hit after Wait returns. Production callers (the simulator harness) honour that invariant by design.
func (*RelayerCacheServer) GetRelay ¶
func (s *RelayerCacheServer) GetRelay(ctx context.Context, relayCacheGet *relaytypes.RelayCacheGet) (*relaytypes.CacheRelayReply, error)
func (*RelayerCacheServer) Health ¶
func (s *RelayerCacheServer) Health(ctx context.Context, req *emptypb.Empty) (*relaytypes.CacheUsage, error)
func (*RelayerCacheServer) PrintCacheStats ¶
func (s *RelayerCacheServer) PrintCacheStats(ctx context.Context, desc string)
func (*RelayerCacheServer) SetRelay ¶
func (s *RelayerCacheServer) SetRelay(ctx context.Context, relayCacheSet *relaytypes.RelayCacheSet) (*emptypb.Empty, error)