distcache

package
v0.27.0-rc.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 10, 2023 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Overview

+kubebuilder:validation:Optional

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Module

func Module() fx.Option

Module provides a new DistCache FX module.

func Register added in v0.20.0

func Register(handler *DistCacheService,
	server *grpc.Server,
	healthsrv *health.Server,
) error

Register registers the handler on grpc.Server.

Types

type DistCache

type DistCache struct {
	sync.Mutex
	Config  *olricconfig.Config
	Olric   *olric.Olric
	Metrics *DistCacheMetrics
}

DistCache is a peer to peer distributed cache.

func (*DistCache) AddDMapCustomConfig

func (dc *DistCache) AddDMapCustomConfig(name string, dmapConfig olricconfig.DMap)

AddDMapCustomConfig adds a named DMap config into DistCache's config. If a custom config with the name does not exist, it is added. If it already exists, it is overwritten.

func (*DistCache) RemoveDMapCustomConfig

func (dc *DistCache) RemoveDMapCustomConfig(name string)

RemoveDMapCustomConfig removes a named DMap config from DistCache's config.

type DistCacheConfig

type DistCacheConfig struct {
	// BindAddr denotes the address that DistCache will bind to for communication with other peer nodes.
	BindAddr string `json:"bind_addr" default:":3320" validate:"hostname_port"`
	// Address to bind mememberlist server to.
	MemberlistBindAddr string `json:"memberlist_bind_addr" default:":3322" validate:"hostname_port"`
	// Address of memberlist to advertise to other cluster members. Used for nat traversal if provided.
	MemberlistAdvertiseAddr string `json:"memberlist_advertise_addr" validate:"omitempty,hostname_port"`
	// ReplicaCount is 1 by default.
	ReplicaCount int `json:"replica_count" default:"1"`
}

DistCacheConfig configures distributed cache that holds per-label counters in distributed rate limiters. swagger:model +kubebuilder:object:generate=true

func (*DistCacheConfig) DeepCopy added in v0.1.2

func (in *DistCacheConfig) DeepCopy() *DistCacheConfig

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DistCacheConfig.

func (*DistCacheConfig) DeepCopyInto added in v0.1.2

func (in *DistCacheConfig) DeepCopyInto(out *DistCacheConfig)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

type DistCacheConstructor

type DistCacheConstructor struct {
	ConfigKey     string
	DefaultConfig DistCacheConfig
}

DistCacheConstructor holds fields to create an instance of DistCache.

func (DistCacheConstructor) ProvideDistCache

func (constructor DistCacheConstructor) ProvideDistCache(in DistCacheConstructorIn) (*DistCache, error)

ProvideDistCache creates a new instance of distributed cache. It also hooks in the service discovery plugin.

type DistCacheConstructorIn

type DistCacheConstructorIn struct {
	fx.In
	PeerDiscovery      *peers.PeerDiscovery
	PrometheusRegistry *prometheus.Registry
	LivenessMultiJob   *jobs.MultiJob `name:"liveness.service"`
	Unmarshaller       config.Unmarshaller
	Lifecycle          fx.Lifecycle
	Shutdowner         fx.Shutdowner
	Logger             *log.Logger
}

DistCacheConstructorIn holds parameters of ProvideDistCache.

type DistCacheMetrics added in v0.5.0

type DistCacheMetrics struct {
	EntriesTotal *prometheus.GaugeVec
	DeleteHits   *prometheus.GaugeVec
	DeleteMisses *prometheus.GaugeVec
	GetMisses    *prometheus.GaugeVec
	GetHits      *prometheus.GaugeVec
	EvictedTotal *prometheus.GaugeVec
}

DistCacheMetrics holds metrics from DistCache, Olric, DMap statistics.

type DistCacheService added in v0.20.0

type DistCacheService struct {
	distcachev1.UnimplementedDistCacheServiceServer
	Olric *olric.Olric
}

DistCacheService implements distcache.v1 service.

func RegisterDistCacheService added in v0.20.0

func RegisterDistCacheService(distcahce *DistCache) *DistCacheService

RegisterDistCacheService returns a new Handler.

func (*DistCacheService) GetStats added in v0.20.0

func (svc *DistCacheService) GetStats(ctx context.Context, _ *emptypb.Empty) (*distcachev1.Stats, error)

GetStats returns stats of the current Olric member.

type OlricLogWriter added in v0.1.2

type OlricLogWriter struct {
	Logger *log.Logger
}

OlricLogWriter is wrapper around aperture Logger that parse the message before writing to olricConfig.LogOutput.

func (*OlricLogWriter) Write added in v0.1.2

func (ol *OlricLogWriter) Write(message []byte) (int, error)

Write writes the message and logs in aperture Logger format.

type ServiceDiscovery

type ServiceDiscovery struct {
	// contains filtered or unexported fields
}

ServiceDiscovery holds fields needed to implement Olric's Service Discovery interface.

func (*ServiceDiscovery) Close

func (s *ServiceDiscovery) Close() error

Close stops underlying goroutines, if there is any. It should be a blocking call. This method is not implemented.

func (*ServiceDiscovery) Deregister

func (s *ServiceDiscovery) Deregister() error

Deregister removes this node from a service discovery directory. This method is not implemented.

func (*ServiceDiscovery) DiscoverPeers

func (s *ServiceDiscovery) DiscoverPeers() ([]string, error)

DiscoverPeers returns a list of known Olric nodes.

func (*ServiceDiscovery) Initialize

func (s *ServiceDiscovery) Initialize() error

Initialize initializes the plugin: registers some internal data structures, clients etc. This method is not implemented.

func (*ServiceDiscovery) Register

func (s *ServiceDiscovery) Register() error

Register registers this node to a service discovery directory. This method is not implemented.

func (*ServiceDiscovery) SetConfig

func (s *ServiceDiscovery) SetConfig(cfg map[string]interface{}) error

SetConfig registers plugin configuration. This method is not implemented.

func (*ServiceDiscovery) SetLogger

func (s *ServiceDiscovery) SetLogger(l *log.Logger)

SetLogger sets an appropriate logger. This method is not implemented.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL