Documentation
¶
Index ¶
- Variables
- type CachePlugin
- type Plugin
- func (p *Plugin) GetPluginConfig(ctx context.Context, req *structpb.Struct) (*structpb.Struct, error)
- func (p *Plugin) OnConfigLoaded(ctx context.Context, req *structpb.Struct) (*structpb.Struct, error)
- func (p *Plugin) OnTrafficFromClient(ctx context.Context, req *structpb.Struct) (*structpb.Struct, error)
- func (p *Plugin) OnTrafficFromServer(ctx context.Context, resp *structpb.Struct) (*structpb.Struct, error)
Constants ¶
This section is empty.
Variables ¶
View Source
var ( CacheHitsCounter = promauto.NewCounter(prometheus.CounterOpts{ Namespace: metrics.Namespace, Name: "cache_hits_total", Help: "The total number of cache hits", }) CacheMissesCounter = promauto.NewCounter(prometheus.CounterOpts{ Namespace: metrics.Namespace, Name: "cache_misses_total", Help: "The total number of cache misses", }) CacheSetsCounter = promauto.NewCounter(prometheus.CounterOpts{ Namespace: metrics.Namespace, Name: "cache_sets_total", Help: "The total number of cache sets", }) CacheGetsCounter = promauto.NewCounter(prometheus.CounterOpts{ Namespace: metrics.Namespace, Name: "cache_gets_total", Help: "The total number of cache gets", }) )
View Source
var ( PluginID = v1.PluginID{ Name: "gatewayd-plugin-cache", Version: "0.0.1", RemoteUrl: "github.com/gatewayd-io/gatewayd-plugin-cache", } PluginMap = map[string]goplugin.Plugin{ PluginID.Name: &CachePlugin{}, } PluginConfig = map[string]interface{}{ "id": map[string]interface{}{ "name": PluginID.Name, "version": PluginID.Version, "remoteUrl": PluginID.RemoteUrl, }, "description": "GatewayD plugin for caching query results", "authors": []interface{}{ "Mostafa Moradian <mostafa@gatewayd.io>", }, "license": "Apache-2.0", "projectUrl": "https://github.com/gatewayd-io/gatewayd-plugin-cache", "config": map[string]interface{}{ "metricsEnabled": sdkConfig.GetEnv("METRICS_ENABLED", "true"), "metricsUnixDomainSocket": sdkConfig.GetEnv( "METRICS_UNIX_DOMAIN_SOCKET", "/tmp/gatewayd-plugin-cache.sock"), "metricsEndpoint": sdkConfig.GetEnv("METRICS_ENDPOINT", "/metrics"), "expiry": sdkConfig.GetEnv("EXPIRY", "1h"), }, "hooks": []interface{}{ "onConfigLoaded", "onTrafficFromClient", "onTrafficFromServer", }, "tags": []interface{}{"test", "plugin"}, "categories": []interface{}{"test"}, } )
Functions ¶
This section is empty.
Types ¶
type CachePlugin ¶
type CachePlugin struct {
goplugin.NetRPCUnsupportedPlugin
Impl Plugin
}
func NewCachePlugin ¶
func NewCachePlugin(impl Plugin) *CachePlugin
NewCachePlugin returns a new instance of the CachePlugin.
func (*CachePlugin) GRPCClient ¶
func (p *CachePlugin) GRPCClient(ctx context.Context, b *goplugin.GRPCBroker, c *grpc.ClientConn) (interface{}, error)
GRPCClient returns the plugin client.
func (*CachePlugin) GRPCServer ¶
func (p *CachePlugin) GRPCServer(b *goplugin.GRPCBroker, s *grpc.Server) error
GRPCServer registers the plugin with the gRPC server.
type Plugin ¶
type Plugin struct {
goplugin.GRPCPlugin
v1.GatewayDPluginServiceServer
Logger hclog.Logger
RedisStore *redis.RedisStore
}
func (*Plugin) GetPluginConfig ¶
func (p *Plugin) GetPluginConfig( ctx context.Context, req *structpb.Struct) (*structpb.Struct, error)
GetPluginConfig returns the plugin config.
func (*Plugin) OnConfigLoaded ¶
func (p *Plugin) OnConfigLoaded( ctx context.Context, req *structpb.Struct) (*structpb.Struct, error)
OnConfigLoaded is called when the global config is loaded by GatewayD.
Click to show internal directories.
Click to hide internal directories.