Documentation
¶
Index ¶
- Variables
- func NewMetricsFactory(extra ...grpcmetrics.Option) grpcmetrics.Factory
- type Config
- type FWStateModule
- func (m *FWStateModule) Close() error
- func (m *FWStateModule) Endpoint() string
- func (m *FWStateModule) Name() string
- func (m *FWStateModule) RegisterService(server *grpc.Server)
- func (m *FWStateModule) ServicesNames() []string
- func (m *FWStateModule) UnaryServerInterceptors() []grpc.UnaryServerInterceptor
- type FWStateService
- func (m *FWStateService) DeleteConfig(ctx context.Context, req *fwstatepb.DeleteConfigRequest) (*fwstatepb.DeleteConfigResponse, error)
- func (m *FWStateService) ListConfigs(ctx context.Context, req *fwstatepb.ListConfigsRequest) (*fwstatepb.ListConfigsResponse, error)
- func (m *FWStateService) Metrics(tags ...*commonpb.MetricTag) ([]*commonpb.Metric, error)
- func (m *FWStateService) ReclaimDeferred()
- func (m *FWStateService) ShowConfig(ctx context.Context, req *fwstatepb.ShowConfigRequest) (*fwstatepb.ShowConfigResponse, error)
- func (m *FWStateService) UnaryServerInterceptor() grpc.UnaryServerInterceptor
- func (m *FWStateService) UpdateConfig(ctx context.Context, req *fwstatepb.UpdateConfigRequest) (*fwstatepb.UpdateConfigResponse, error)
- type FwStateConfig
- type MetricsService
- type MutationObserver
- type Option
Constants ¶
This section is empty.
Variables ¶
var ( FWStateServiceName = fwstatepb.FWStateService_ServiceDesc.ServiceName FWStateMetricsServiceName = fwstatepb.MetricsService_ServiceDesc.ServiceName )
FWStateServiceName and MetricsServiceName are the fully-qualified gRPC service names exposed by this module, derived from the generated service descriptors so they cannot drift from the proto definitions.
They are used to scope the module's grpcmetrics.ServerMetrics to its own services when several modules share a single grpc.Server.
Functions ¶
func NewMetricsFactory ¶
func NewMetricsFactory(extra ...grpcmetrics.Option) grpcmetrics.Factory
NewMetricsFactory returns a grpcmetrics.Factory pre-bound to this module's own labeler and service filter, applying any extra options (e.g. custom histogram buckets) supplied by the caller.
The grpcmetrics.Retention is injected by the service itself at construction time, so it must not be passed here.
Types ¶
type Config ¶
type Config struct {
// InstanceID specifies which dataplane instance this module serves.
//
// Required: a listed module must set it explicitly, even to 0.
InstanceID xcfg.Required[uint32] `yaml:"instance_id"`
// MemoryPath is the path to the shared memory file
MemoryPath xcfg.NonEmptyString `yaml:"memory_path"`
// MemoryRequirements specifies memory requirements for the module
MemoryRequirements xcfg.NonZero[datasize.ByteSize] `yaml:"memory_requirements"`
// Endpoint is the gRPC endpoint address
Endpoint xcfg.NonEmptyString `yaml:"endpoint"`
}
Config represents FWState module configuration
type FWStateModule ¶
type FWStateModule struct {
// contains filtered or unexported fields
}
FWStateModule is a control-plane component of the firewall-state sync module.
The module shares state with ACL solely through named fwstate-map objects: the map service publishes them into the instance-wide config generation, where module configs of any agent resolve them by name.
func NewFWStateModule ¶
func NewFWStateModule(cfg *Config, options ...Option) (*FWStateModule, error)
NewFWStateModule creates a new fwstate module instance.
func (*FWStateModule) Endpoint ¶
func (m *FWStateModule) Endpoint() string
func (*FWStateModule) Name ¶
func (m *FWStateModule) Name() string
func (*FWStateModule) RegisterService ¶
func (m *FWStateModule) RegisterService(server *grpc.Server)
func (*FWStateModule) ServicesNames ¶
func (m *FWStateModule) ServicesNames() []string
func (*FWStateModule) UnaryServerInterceptors ¶
func (m *FWStateModule) UnaryServerInterceptors() []grpc.UnaryServerInterceptor
UnaryServerInterceptors returns the gRPC unary interceptors for this module.
type FWStateService ¶
type FWStateService struct {
fwstatepb.UnimplementedFWStateServiceServer
// contains filtered or unexported fields
}
FWStateService implements the gRPC service for FWState management.
func NewFWStateService ¶
func NewFWStateService( agent *ffi.Agent, options ...Option, ) *FWStateService
NewFWStateService creates a new FWState service.
When the WithMetrics option is supplied, gRPC call metrics are collected and exposed through the module's MetricsService.
func (*FWStateService) DeleteConfig ¶
func (m *FWStateService) DeleteConfig( ctx context.Context, req *fwstatepb.DeleteConfigRequest, ) (*fwstatepb.DeleteConfigResponse, error)
func (*FWStateService) ListConfigs ¶
func (m *FWStateService) ListConfigs( ctx context.Context, req *fwstatepb.ListConfigsRequest, ) (*fwstatepb.ListConfigsResponse, error)
func (*FWStateService) Metrics ¶
Metrics returns FWState module metrics matching tags: dataplane counters and gRPC call metrics.
Labels:
- config: fwstate config name (all metrics)
- grpc_type: always "unary" (gRPC metrics)
- grpc_service: fully-qualified gRPC service name (gRPC metrics)
- grpc_method: RPC name (gRPC metrics)
- grpc_code: gRPC status code string (grpc_server_handled_total only)
func (*FWStateService) ReclaimDeferred ¶
func (m *FWStateService) ReclaimDeferred()
ReclaimDeferred retries every deferred config, dropping the ones whose generations have drained and keeping the rest deferred. It is the reclamation handler for this module's superseded configs; the service itself runs it after each successful publish, and anything else may call it at any time.
func (*FWStateService) ShowConfig ¶
func (m *FWStateService) ShowConfig( ctx context.Context, req *fwstatepb.ShowConfigRequest, ) (*fwstatepb.ShowConfigResponse, error)
func (*FWStateService) UnaryServerInterceptor ¶
func (m *FWStateService) UnaryServerInterceptor() grpc.UnaryServerInterceptor
UnaryServerInterceptor returns the service's gRPC metrics interceptor, or nil when metrics are not configured.
func (*FWStateService) UpdateConfig ¶
func (m *FWStateService) UpdateConfig( ctx context.Context, req *fwstatepb.UpdateConfigRequest, ) (*fwstatepb.UpdateConfigResponse, error)
type FwStateConfig ¶
type FwStateConfig struct {
*cfwstate.ModuleConfig
// contains filtered or unexported fields
}
FwStateConfig is a service-owned fwstate module config plus the names of the fwstate-map objects it links, which the service needs for ShowConfig and for stats and entry reads delegated to the map objects.
func NewFWStateModuleConfig ¶
func NewFWStateModuleConfig( agent *ffi.Agent, name string, old *FwStateConfig, syncConfig *fwstatepb.SyncConfig, fw4MapName, fw6MapName string, ) (*FwStateConfig, error)
NewFWStateModuleConfig builds the config in one step: the request's sync config merges over the replaced config's values (or the defaults for a fresh config) and both map names are declared as object links, resolving against published objects when the config is published.
The map names are remembered only after the C construction succeeds, so a failed construction leaves the previous linkage visible to readers.
func (*FwStateConfig) GetSyncConfig ¶
func (m *FwStateConfig) GetSyncConfig() *fwstatepb.SyncConfig
func (*FwStateConfig) MapNameV4 ¶
func (m *FwStateConfig) MapNameV4() string
MapNameV4 returns the name of the linked IPv4 fwstate-map object.
func (*FwStateConfig) MapNameV6 ¶
func (m *FwStateConfig) MapNameV6() string
MapNameV6 returns the name of the linked IPv6 fwstate-map object.
func (*FwStateConfig) MergedSyncConfig ¶
func (m *FwStateConfig) MergedSyncConfig(syncConfig *fwstatepb.SyncConfig) *fwstatepb.SyncConfig
MergedSyncConfig returns the request's sync config merged with the defaults: the exact values a fresh construction would install.
type MetricsService ¶
type MetricsService struct {
fwstatepb.UnimplementedMetricsServiceServer
// contains filtered or unexported fields
}
MetricsService exposes FWState module metrics over its own gRPC service.
It aggregates every source supplied at construction: the fwstate service's dataplane counters and gRPC call metrics, plus the map service's per-map gauge series and gRPC call metrics for the RPCs the module also serves.
func NewMetricsService ¶
func NewMetricsService(sources ...metricsSource) *MetricsService
NewMetricsService creates a MetricsService backed by sources.
func (*MetricsService) GetMetrics ¶
func (m *MetricsService) GetMetrics( ctx context.Context, req *commonpb.GetMetricsRequest, ) (*commonpb.GetMetricsResponse, error)
GetMetrics returns a snapshot of FWState module metrics matching the request's tags.
type MutationObserver ¶
type MutationObserver interface {
ObserveFWStateMutation(operation, phase string)
}
MutationObserver observes updateMu acquisition for a mutation, before Lock, after Lock succeeds, and immediately before Unlock. It observes synchronization but never controls it, and lets tests prove ordering between concurrent mutations.
type Option ¶
type Option func(*options)
Option configures an FWStateService.
func WithMetrics ¶
func WithMetrics(factory grpcmetrics.Factory) Option
WithMetrics enables collection of gRPC call metrics using the supplied factory.
The factory owns label extraction and bucketing. The service injects its own retention provider at construction time. Use NewMetricsFactory to build a factory scoped to this module's services.
func WithMutationObserver ¶
func WithMutationObserver(observer MutationObserver) Option
WithMutationObserver installs an observer receiving every mutation's lock lifecycle events.