topology

package
v14.47.0 Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2026 License: MIT Imports: 19 Imported by: 0

Documentation

Overview

Package topology provides a client for interacting with the GitLab Cells Topology Service.

The Topology Service is a gRPC server that provides cell routing information for requests related to specific records (projects, groups, etc.) in a GitLab Cells architecture.

Configuration is done via the topology_service section in config.yml:

topology_service:
  enabled: true
  address: "topology.gitlab.com:443"
  classify_type: "first_cell"
  tls:
    enabled: true
    ca_file: "/path/to/ca.crt"

For more details, see:

Index

Constants

View Source
const (
	ClassifyTypeFirstCell     = pb.ClassifyType_FIRST_CELL
	ClassifyTypeSessionPrefix = pb.ClassifyType_SESSION_PREFIX
	ClassifyTypeCellID        = pb.ClassifyType_CELL_ID
)

ClassifyType constants mirror the proto enum values for convenience.

View Source
const DefaultTimeout = 5 * time.Second

DefaultTimeout is the default timeout for Topology Service requests.

Variables

View Source
var ValidClassifyTypes = []string{"first_cell", "session_prefix", "cell_id"}

ValidClassifyTypes contains the list of valid classify_type values. These correspond to the ClassifyType enum in the Topology Service proto.

Functions

This section is empty.

Types

type Client added in v14.47.0

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

Client provides a gRPC client for the Topology Service. It handles connection management with lazy initialization and supports TLS/mTLS for secure connections.

func NewClient added in v14.47.0

func NewClient(cfg *Config) *Client

NewClient creates a new Topology Service client from the given configuration. Returns nil if the topology service is disabled in the configuration. The client uses lazy initialization - the actual gRPC connection is established on the first call to Classify. The configuration is copied to avoid mutating the original.

func (*Client) Classify added in v14.47.0

func (c *Client) Classify(ctx context.Context, value string) (*pb.ClassifyResponse, error)

Classify queries the Topology Service to determine which cell should handle a request for the given value. The value interpretation depends on the configured ClassifyType (e.g., project path, session prefix, cell ID).

func (*Client) Close added in v14.47.0

func (c *Client) Close() error

Close closes the gRPC connection to the Topology Service. It is safe to call Close multiple times.

type Config

type Config struct {
	// Enabled indicates whether Topology Service integration is enabled.
	Enabled bool `yaml:"enabled"`

	// Address is the gRPC address of the Topology Service (e.g., "topology.gitlab.com:443").
	Address string `yaml:"address"`

	// ClassifyType specifies which ClassifyType to use when querying the service.
	// Valid values: "first_cell", "session_prefix", "cell_id".
	// Default: "first_cell" (applied at runtime when empty).
	ClassifyType string `yaml:"classify_type"`

	// Timeout is the maximum duration to wait for a response from the Topology Service.
	// Default: 5s (when zero).
	Timeout time.Duration `yaml:"timeout"`

	// TLS contains TLS configuration for secure connections.
	TLS TLSConfig `yaml:"tls"`
}

Config contains Topology Service client configuration settings.

func (*Config) Validate

func (c *Config) Validate() error

Validate validates the Topology Service configuration.

type TLSConfig

type TLSConfig struct {
	// Enabled indicates whether TLS should be used for the connection.
	Enabled bool `yaml:"enabled"`

	// CAFile is the path to the CA certificate file for server verification.
	// If empty, system CA certificates will be used.
	CAFile string `yaml:"ca_file"`

	// CertFile is the path to the client certificate file (for mTLS).
	// Must be provided together with KeyFile.
	CertFile string `yaml:"cert_file"`

	// KeyFile is the path to the client key file (for mTLS).
	// Must be provided together with CertFile.
	KeyFile string `yaml:"key_file"`

	// ServerName is the expected server name for TLS verification.
	// If empty, the hostname from Address will be used.
	ServerName string `yaml:"server_name"`

	// InsecureSkipVerify skips TLS certificate verification.
	// WARNING: This should only be used for development/testing.
	InsecureSkipVerify bool `yaml:"insecure_skip_verify"`
}

TLSConfig contains TLS settings for the Topology Service connection.

func (*TLSConfig) Validate

func (c *TLSConfig) Validate() error

Validate validates the TLS configuration.

Jump to

Keyboard shortcuts

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