ancla

package module
v0.4.8 Latest Latest
Warning

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

Go to latest
Published: May 1, 2026 License: Apache-2.0 Imports: 17 Imported by: 3

README

ancla

Provides a configurable wrpEventStream registry component for XMiDT services. Application code can use the registry directly or as a plug-in for ancla's helper HTTP handlers.

Build Status codecov.io Go Report Card Apache V2 License GitHub Release GoDoc

Maintenance Instructions

This repository uses shared-go for it's workflows. Here is documentation for how to best maintain this repository.

Code of Conduct

This project and everyone participating in it are governed by the XMiDT Code Of Conduct. By participating, you agree to this Code.

Contributing

Refer to CONTRIBUTING.md.

Documentation

Overview

SPDX-FileCopyrightText: 2022 Comcast Cable Communications Management, LLC SPDX-License-Identifier: Apache-2.0

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultBasicPartnerIDsHeader = "X-Xmidt-Partner-Ids"
)

Functions

func NewAddWRPEventStreamHandler added in v0.4.0

func NewAddWRPEventStreamHandler(s Service, config HandlerConfig) http.Handler

NewAddWRPEventStreamHandler returns an HTTP handler for adding a wrpEventStream registration.

func NewGetAllWRPEventStreamsHandler added in v0.4.0

func NewGetAllWRPEventStreamsHandler(s Service, config HandlerConfig) http.Handler

NewGetAllWRPEventStreamsHandler returns an HTTP handler for fetching all the currently registered wrpEventStreams.

func NewService added in v0.3.10

func NewService(client chrysom.PushReader) *service

NewService returns an ancla client used to interact with an Argus database.

Types

type Config

type Config struct {
	// DisablePartnerIDs, if true, will allow wrpEventStreams to register without
	// checking the validity of the partnerIDs in the request.
	DisablePartnerIDs bool

	// Validation provides options for validating the wrpEventStream's URL and TTL
	// related fields. Some validation happens regardless of the configuration:
	// URLs must be a valid URL structure, the Matcher.DeviceID values must
	// compile into regular expressions, and the Events field must have at
	// least one value and all values must compile into regular expressions.
	Validation schema.SchemaURLValidatorConfig
}

Config contains information needed to initialize the Argus database client.

type DefaultListenerOut added in v0.4.0

type DefaultListenerOut struct {
	fx.Out

	Watchers []Watch `group:"watchers,flatten"`
}

func ProvideDefaultListenerWatchers added in v0.4.0

func ProvideDefaultListenerWatchers(in DefaultListenersIn) DefaultListenerOut

type DefaultListenersIn added in v0.4.0

type DefaultListenersIn struct {
	fx.In

	// Metric for wrpEventStream list size, used by the wrpEventStream list size watcher listener.
	WRPEventStreamListSizeGauge prometheus.Gauge `name:"wrp_event_stream_list_size"`
}

TODO: Refactor and move Watch and ListenerInterface related code to chrysom.

type HandlerConfig added in v0.1.1

type HandlerConfig struct {
	V                 webhook.Validators
	DisablePartnerIDs bool
	GetLogger         func(context.Context) *zap.Logger
}

HandlerConfig contains configuration for all components that handlers depend on from the service to the transport layers.

type ListenerIn added in v0.4.0

type ListenerIn struct {
	fx.In

	Shutdowner fx.Shutdowner
	// Watchers are called by the Listener when new wrpEventStreams are fetched.
	Watchers []Watch `group:"watchers"`
}

type ListenerOut added in v0.4.0

type ListenerOut struct {
	fx.Out

	Option chrysom.ListenerOption `group:"listener_options"`
}

ListenerOut contains options data for Listener client's reader.

func ProvideListener added in v0.4.0

func ProvideListener(in ListenerIn) ListenerOut

type Service

type Service interface {
	// Add adds the given owned wrpEventStream to the current list of wrpEventStreams. If the operation
	// succeeds, a non-nil error is returned.
	Add(ctx context.Context, owner string, iw schema.Manifest) error

	// GetAll lists all the current registered wrpEventStreams.
	GetAll(ctx context.Context) ([]schema.Manifest, error)
}

Service describes the core operations around wrpEventStream subscriptions.

func ProvideService added in v0.4.0

func ProvideService(in ServiceIn) (Service, error)

ProvideService provides the Argus client service from the given configuration.

type ServiceIn added in v0.4.0

type ServiceIn struct {
	fx.In

	// PushReader is the user provided db client.
	PushReader chrysom.PushReader `optional:"true"`
}

type Watch

type Watch interface {
	Update([]schema.Manifest)
}

Watch is the interface for listening for wrpEventStream subcription updates. Updates represent the latest known list of subscriptions.

type WatchFunc

type WatchFunc func([]schema.Manifest)

WatchFunc allows bare functions to pass as Watches.

func (WatchFunc) Update

func (f WatchFunc) Update(update []schema.Manifest)

Directories

Path Synopsis
SPDX-FileCopyrightText: 2025 Comcast Cable Communications Management, LLC SPDX-License-Identifier: Apache-2.0
SPDX-FileCopyrightText: 2025 Comcast Cable Communications Management, LLC SPDX-License-Identifier: Apache-2.0
SPDX-FileCopyrightText: 2025 Comcast Cable Communications Management, LLC SPDX-License-Identifier: Apache-2.0
SPDX-FileCopyrightText: 2025 Comcast Cable Communications Management, LLC SPDX-License-Identifier: Apache-2.0

Jump to

Keyboard shortcuts

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