service

package
v3.13.0 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2026 License: Apache-2.0 Imports: 43 Imported by: 0

Documentation

Overview

Package service hosts the registry-backed peer resolver embedded by every reva service across all transports. It is neutral (imports only CS3 client types and the registry) to avoid an import cycle.

Index

Constants

View Source
const (
	NameGateway         = "gateway"
	NameStorageProvider = "storageprovider"
	NameStorageRegistry = "storageregistry"
	NameAuthProvider    = "authprovider"
	NameAuthRegistry    = "authregistry"
	NameAppAuthProvider = "applicationauth"
	NameUserProvider    = "userprovider"
	NameGroupProvider   = "groupprovider"
	NameUserShare       = "usershareprovider"
	NamePublicShare     = "publicshareprovider"
	NameOCMShare        = "ocmshareprovider"
	NameOCMInvite       = "ocminvitemanager"
	NameOCMProvider     = "ocmproviderauthorizer"
	NameOCMIncoming     = "ocmincoming"
	NamePreferences     = "preferences"
	NamePermissions     = "permissions"
	NameAppRegistry     = "appregistry"
	NameAppProvider     = "appprovider"
	NameSpaces          = "spacesregistry"
	NameDataTx          = "datatx"
	NameLabels          = "labelsprovider"
	NameAdmin           = "admin"
	// NameControl labels the per-process control channel on its internal
	// server; it is discovered via node metadata, not registered as a service.
	NameControl = "control"
)

Service names processes register under and the resolver looks up.

Variables

This section is empty.

Functions

func AppAuthProvider

AppAuthProvider resolves the application auth provider through the global resolver.

func AppProvider

AppProvider resolves the app provider through the global resolver.

func AppProviderAt

func AppProviderAt(address string) (appprovider.ProviderAPIClient, error)

AppProviderAt returns an app provider client for an explicit address.

func AppRegistry

AppRegistry resolves the app registry through the global resolver.

func AuthProvider

func AuthProvider(ctx context.Context) (authprovider.ProviderAPIClient, error)

AuthProvider resolves the auth provider through the global resolver.

func AuthProviderAt

func AuthProviderAt(address string) (authprovider.ProviderAPIClient, error)

AuthProviderAt returns an auth provider client for an explicit address.

func AuthRegistry

func AuthRegistry(ctx context.Context) (authregistry.RegistryAPIClient, error)

AuthRegistry resolves the auth registry through the global resolver.

func DataTx

func DataTx(ctx context.Context) (datatx.TxAPIClient, error)

DataTx resolves the data transfer service through the global resolver.

func Degrade

func Degrade(service, address string)

Degrade marks the node at address degraded on the global resolver.

func Gateway

Gateway resolves the gateway through the global resolver.

func GatewayAt

func GatewayAt(address string) (gateway.GatewayAPIClient, error)

GatewayAt returns a gateway client for an explicit address.

func GlobalRegistry

func GlobalRegistry() registry.Registry

GlobalRegistry returns the process-wide registry, or nil if none was set.

func GroupProvider

func GroupProvider(ctx context.Context) (group.GroupAPIClient, error)

GroupProvider resolves the group provider through the global resolver.

func Labels

Labels resolves the labels service through the global resolver.

func OCMIncoming

OCMIncoming resolves the OCM incoming service through the global resolver.

func OCMInviteManager

func OCMInviteManager(ctx context.Context) (invitepb.InviteAPIClient, error)

OCMInviteManager resolves the OCM invite manager through the global resolver.

func OCMProviderAuthorizer

func OCMProviderAuthorizer(ctx context.Context) (ocmprovider.ProviderAPIClient, error)

OCMProviderAuthorizer resolves the OCM provider authorizer through the global resolver.

func OCMShareProvider

func OCMShareProvider(ctx context.Context) (ocm.OcmAPIClient, error)

OCMShareProvider resolves the OCM share provider through the global resolver.

func Permissions

Permissions resolves the permissions service through the global resolver.

func Preferences

Preferences resolves the preferences service through the global resolver.

func PublicShareProvider

func PublicShareProvider(ctx context.Context) (link.LinkAPIClient, error)

PublicShareProvider resolves the public share provider through the global resolver.

func SetClientAt

func SetClientAt(address string, client any)

SetClientAt pins client to address, so the *At getters below return it rather than dialing. It exists for tests: a fake peer has no listener to dial, but the code under test still reaches it by the address a registry lookup handed back. Pass a nil client to drop the pin.

func SetGlobal

func SetGlobal(c Clients)

SetGlobal installs the process-wide peer resolver. The first non-nil resolver wins; later calls are ignored. The runtime sets it once at startup so any component can resolve peers without being explicitly wired.

func SetGlobalRegistry

func SetGlobalRegistry(r registry.Registry)

SetGlobalRegistry installs the process-wide service registry handle. The first non-nil registry wins; later calls are ignored.

func Spaces

Spaces resolves the spaces registry through the global resolver.

func StorageProvider

func StorageProvider(ctx context.Context) (storageprovider.ProviderAPIClient, error)

StorageProvider resolves the storage provider through the global resolver.

func StorageProviderAt

func StorageProviderAt(address string) (storageprovider.ProviderAPIClient, error)

StorageProviderAt returns a storage provider client for an explicit address.

func StorageRegistry

func StorageRegistry(ctx context.Context) (storageregistry.RegistryAPIClient, error)

StorageRegistry resolves the storage registry through the global resolver.

func StorageRegistryAt

func StorageRegistryAt(address string) (storageregistry.RegistryAPIClient, error)

StorageRegistryAt returns a storage registry client for an explicit address.

func UserProvider

func UserProvider(ctx context.Context) (user.UserAPIClient, error)

UserProvider resolves the user provider through the global resolver.

func UserProviderAt

func UserProviderAt(address string) (user.UserAPIClient, error)

UserProviderAt returns a user provider client for an explicit address.

func UserShareProvider

func UserShareProvider(ctx context.Context) (collaboration.CollaborationAPIClient, error)

UserShareProvider resolves the user share provider through the global resolver.

Types

type Clients

type Clients interface {
	Gateway(ctx context.Context) (gateway.GatewayAPIClient, error)
	StorageProvider(ctx context.Context) (storageprovider.ProviderAPIClient, error)
	StorageRegistry(ctx context.Context) (storageregistry.RegistryAPIClient, error)
	Spaces(ctx context.Context) (storageprovider.SpacesAPIClient, error)
	AuthProvider(ctx context.Context) (authprovider.ProviderAPIClient, error)
	AuthRegistry(ctx context.Context) (authregistry.RegistryAPIClient, error)
	AppAuthProvider(ctx context.Context) (applicationauth.ApplicationsAPIClient, error)
	UserProvider(ctx context.Context) (user.UserAPIClient, error)
	GroupProvider(ctx context.Context) (group.GroupAPIClient, error)
	UserShareProvider(ctx context.Context) (collaboration.CollaborationAPIClient, error)
	PublicShareProvider(ctx context.Context) (link.LinkAPIClient, error)
	OCMShareProvider(ctx context.Context) (ocm.OcmAPIClient, error)
	OCMInviteManager(ctx context.Context) (invitepb.InviteAPIClient, error)
	OCMProviderAuthorizer(ctx context.Context) (ocmprovider.ProviderAPIClient, error)
	OCMIncoming(ctx context.Context) (ocmincoming.OcmIncomingAPIClient, error)
	Preferences(ctx context.Context) (preferences.PreferencesAPIClient, error)
	Permissions(ctx context.Context) (permissions.PermissionsAPIClient, error)
	AppRegistry(ctx context.Context) (appregistry.RegistryAPIClient, error)
	AppProvider(ctx context.Context) (appprovider.ProviderAPIClient, error)
	DataTx(ctx context.Context) (datatx.TxAPIClient, error)
	Labels(ctx context.Context) (labels.LabelsAPIClient, error)

	// Degrade marks the node at address degraded and passes it over locally.
	Degrade(service, address string)

	// HTTPEndpoint resolves one ready node matching the filters; HTTPEndpoints
	// returns all of them. Used for HTTP services whose URL is needed (data
	// gateway, data provider).
	HTTPEndpoint(ctx context.Context, opts ...EndpointOption) (Endpoint, error)
	HTTPEndpoints(ctx context.Context, opts ...EndpointOption) ([]Endpoint, error)
}

Clients resolves a peer by kind and returns a typed CS3 client; resolution, selection and dialing happen below the call.

func Global

func Global() Clients

Global returns the process-wide resolver, or nil if none was set.

func NewClients

func NewClients(r registry.Registry) Clients

NewClients builds a resolver over the registry, one per Reva instance.

type Endpoint

type Endpoint interface {
	Name() string    // service name
	Address() string // bind "host:port"
	Host() string
	Port() string
	Scheme() string              // "http" | "https"
	Prefix() string              // URL path prefix
	URL() string                 // public_url, else scheme://address/prefix
	Meta(key string) string      // single metadata value
	Metadata() map[string]string // all advertised metadata
	Node() registry.Node         // raw node
}

Endpoint is a resolved registry node with convenience accessors over its address and metadata. It is returned by HTTPEndpoint(s) for services whose reachable URL another service needs (data gateway, data provider, ...).

func HTTPEndpoint

func HTTPEndpoint(ctx context.Context, opts ...EndpointOption) (Endpoint, error)

HTTPEndpoint resolves one ready HTTP endpoint matching the filters through the global resolver.

func HTTPEndpoints

func HTTPEndpoints(ctx context.Context, opts ...EndpointOption) ([]Endpoint, error)

HTTPEndpoints resolves every ready HTTP endpoint matching the filters through the global resolver.

type EndpointOption

type EndpointOption func(*endpointQuery)

EndpointOption narrows the candidate node set.

func ByMetadata

func ByMetadata(key, value string) EndpointOption

ByMetadata keeps only nodes whose metadata[key] == value. Repeatable.

func ByName

func ByName(name string) EndpointOption

ByName selects a service by registry name.

type FirstSelector

type FirstSelector struct{}

FirstSelector returns the first selectable node (the default).

func (FirstSelector) Pick

func (FirstSelector) Pick(nodes []registry.Node) (registry.Node, bool)

type MetadataProvider

type MetadataProvider interface {
	RegistryMetadata() map[string]string
}

MetadataProvider is implemented by a service that wants to advertise extra metadata (e.g. mount_id, public_url) on its registry node. The runtime merges RegistryMetadata() over the framework-derived keys at registration.

type RandomSelector

type RandomSelector struct{}

func (RandomSelector) Pick

func (RandomSelector) Pick(nodes []registry.Node) (registry.Node, bool)

type RoundRobinSelector

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

func (*RoundRobinSelector) Pick

func (s *RoundRobinSelector) Pick(nodes []registry.Node) (registry.Node, bool)

type Selector

type Selector interface {
	Pick(nodes []registry.Node) (registry.Node, bool)
}

Selector picks one node, preferring ready over degraded and never offline or draining.

Jump to

Keyboard shortcuts

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