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) Run(ctx context.Context) error
- 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) 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 {
ffi.AttachConfig `yaml:",inline"`
// Endpoint is the gRPC endpoint address
Endpoint xcfg.NonEmptyString `yaml:"endpoint"`
// StaleLayerSweepInterval is the period between stale-layer sweeps.
StaleLayerSweepInterval time.Duration `yaml:"stale_layer_sweep_interval"`
}
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) Run ¶ added in v0.1.0
func (m *FWStateModule) Run(ctx context.Context) error
Run reclaims stale map layers until the context is cancelled.
The sweep publishes config generations through the module's agent, so it belongs to the phase that ends before anything is closed rather than to the module's own construction: a module whose ownership never transfers leaves nothing running behind it.
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) 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.
The exposed snapshot — the map names and the sync settings — is captured at construction and never read back from shared memory, so readers may hold a config past its retirement: the Go values stay valid even after the shared-memory handle is freed.
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, ready to publish.
The request's sync settings merge over the values they replace, and each named map is declared as an object link resolving against published objects when the config is published. An empty map name declares no link, and the module then counts and drops that family's synced state. The map names are remembered only after the 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.
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 a mutation's lifecycle in the config store: before it enters the store's writer section, once an admitted mutation is about to touch shared memory inside that section, and as that work ends. A mutation the store rejects before running it — a delete of an unknown name — reports only the first phase. 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.