Help us shape the future of Go! Take the 2026 Go Developer Survey

network

package
v1.20.3 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2026 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Overview

Package network is the facade of the network module: admin-side server and node management, the node-facing server API and the edge client manifest. See docs/design/adr-001-modular-monolith.md.

Index

Constants

This section is empty.

Variables

View Source
var ErrManifestNotFound = edge.ErrManifestNotFound

ErrManifestNotFound re-exports the edge subdomain's not-found sentinel for the transport handler's status mapping.

Functions

func NewRepoBuilder added in v1.15.2

func NewRepoBuilder(rds *redis.Client) repository.NetworkBuilder

NewRepoBuilder exports the module-owned repository implementations for store assembly. The node cache retrier is a background singleton that survives per-transaction rebuilds, so it lives in this closure (ADR-001 step-6 preparation).

Types

type Deps

type Deps struct {
	Store        Store
	TrafficUsage subscription.TrafficUsage
	Redis        *redis.Client
	// Config snapshots the runtime-mutable settings per request.
	Config func() Snapshot
	// Multiplier returns the node traffic multiplier in effect at the given
	// time; nil means no multiplier is configured.
	Multiplier func(at time.Time) float32
}

Deps declares everything the module needs; the composition root (internal/app) provides them. The module wraps the legacy store during migration and will own its persistence once the domain data moves in (ADR-001 step 5).

type MultiplierManager added in v1.20.2

type MultiplierManager = multiplier.Manager

MultiplierManager and MultiplierPeriod expose the network-owned runtime configuration to application assembly without exporting its implementation.

func NewMultiplierManager added in v1.20.2

func NewMultiplierManager(periods []MultiplierPeriod) *MultiplierManager

type MultiplierPeriod added in v1.20.2

type MultiplierPeriod = multiplier.TimePeriod

type RequestMeta

type RequestMeta = serverapi.RequestMeta

RequestMeta and ResponseMeta re-export the server API's conditional-request negotiation types for the transport handlers.

type ResponseMeta

type ResponseMeta = serverapi.ResponseMeta

RequestMeta and ResponseMeta re-export the server API's conditional-request negotiation types for the transport handlers.

type Service

type Service interface {
	// Admin-side server and node management.
	CreateServer(ctx context.Context, req *dto.CreateServerRequest) error
	UpdateServer(ctx context.Context, req *dto.UpdateServerRequest) error
	DeleteServer(ctx context.Context, req *dto.DeleteServerRequest) error
	FilterServerList(ctx context.Context, req *dto.FilterServerListRequest) (*dto.FilterServerListResponse, error)
	ResetSortWithServer(ctx context.Context, req *dto.ResetSortRequest) error
	GetServerProtocols(ctx context.Context, req *dto.GetServerProtocolsRequest) (*dto.GetServerProtocolsResponse, error)
	GetServerNodeConfig(ctx context.Context, req *dto.GetServerNodeConfigRequest) (*dto.GetServerNodeConfigResponse, error)
	UpdateServerNodeConfig(ctx context.Context, req *dto.UpdateServerNodeConfigRequest) error
	CreateNode(ctx context.Context, req *dto.CreateNodeRequest) error
	UpdateNode(ctx context.Context, req *dto.UpdateNodeRequest) error
	DeleteNode(ctx context.Context, req *dto.DeleteNodeRequest) error
	FilterNodeList(ctx context.Context, req *dto.FilterNodeListRequest) (*dto.FilterNodeListResponse, error)
	ToggleNodeStatus(ctx context.Context, req *dto.ToggleNodeStatusRequest) error
	ResetSortWithNode(ctx context.Context, req *dto.ResetSortRequest) error
	QueryNodeTag(ctx context.Context) (*dto.QueryNodeTagResponse, error)

	// The node-facing server API. The ETag negotiation flows through
	// RequestMeta/ResponseMeta; node authentication stays in the handlers.
	GetServerConfig(ctx context.Context, req *dto.GetServerConfigRequest, meta RequestMeta) (*dto.GetServerConfigResponse, ResponseMeta, error)
	GetServerUserList(ctx context.Context, req *dto.GetServerUserListRequest, meta RequestMeta) (*dto.GetServerUserListResponse, ResponseMeta, error)
	QueryServerProtocolConfig(ctx context.Context, req *dto.QueryServerConfigRequest) (*dto.QueryServerConfigResponse, error)
	PushOnlineUsers(ctx context.Context, req *dto.OnlineUsersRequest) error
	ServerPushStatus(ctx context.Context, req *dto.ServerPushStatusRequest) error
	ServerPushUserTraffic(ctx context.Context, req *dto.ServerPushUserTrafficRequest) error

	// EdgeManifest serves the token-authenticated edge client manifest.
	EdgeManifest(ctx context.Context, token string) (*dto.EdgeManifestResponse, error)
}

Service is the only surface other code may depend on; the implementation lives under internal/ where the compiler seals it off.

func New

func New(deps Deps) Service

type Snapshot

type Snapshot struct {
	Node      config.NodeConfig
	Subscribe config.SubscribeConfig
}

Snapshot is the per-request view of the runtime-mutable settings the network flows consume.

type Store added in v1.20.3

type Store interface {
	adminserver.Store
	serverapi.Store
	edge.Store
}

Store is the persistence capability required by this package. It excludes unrelated repositories and application-wide transactions.

type TrafficAggregator added in v1.20.3

type TrafficAggregator = trafficagg.Aggregator

TrafficAggregator is the network-owned pipeline shared by node reports and scheduled flush tasks. Queue adapters enter through this facade.

func NewTrafficAggregator added in v1.20.3

func NewTrafficAggregator(deps TrafficAggregatorDeps) *TrafficAggregator

type TrafficAggregatorDeps added in v1.20.3

type TrafficAggregatorDeps = trafficagg.Deps

type UserTraffic added in v1.20.3

type UserTraffic = trafficagg.UserTraffic

Directories

Path Synopsis
entity
internal
adminserver
Service assembly for the admin-side server and node management subdomain of the network module.
Service assembly for the admin-side server and node management subdomain of the network module.
edge
Service assembly for the edge subdomain of the network module: the token- authenticated client manifest.
Service assembly for the edge subdomain of the network module: the token- authenticated client manifest.
edgeauth
Package edgeauth authenticates Cloudflare edge-subscribe Workers.
Package edgeauth authenticates Cloudflare edge-subscribe Workers.
serverapi
Service assembly for the node-facing server API subdomain of the network module: config pulls, user lists, status/traffic pushes.
Service assembly for the node-facing server API subdomain of the network module: config pulls, user lists, status/traffic pushes.
transport

Jump to

Keyboard shortcuts

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