nameresolution

package
v1.13.1 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2024 License: Apache-2.0 Imports: 4 Imported by: 11

README

Name resolution

Name resolvers provide a common way to interact with different name resolvers, which are used to return the address or IP of other services your applications may connect to.

Implementing a new Name Resolver

A compliant name resolver needs to implement the Resolver inteface included in the nameresolution.go file.

Documentation

Index

Constants

View Source
const (
	// HostAddress is the address of the instance.
	HostAddress string = "HOST_ADDRESS"
	// DaprHTTPPort is the dapr api http port.
	DaprHTTPPort string = "DAPR_HTTP_PORT"
	// DaprPort is the dapr internal grpc port (sidecar to sidecar).
	DaprPort string = "DAPR_PORT"
	// AppPort is the port of the application, http/grpc depending on mode.
	AppPort string = "APP_PORT"
	// AppID is the ID of the application.
	AppID string = "APP_ID"
	// Namespace is the namespace of the application.
	Namespace string = "NAMESPACE"
)

These constants are used for the "legacy" way to pass instance information using a map.

Variables

This section is empty.

Functions

This section is empty.

Types

type AddressList added in v1.12.9

type AddressList []string

AddressList is a list of addresses resolved by the nameresolver

func (AddressList) Pick added in v1.12.9

func (a AddressList) Pick() string

Pick returns a random address from the list

type Instance added in v1.13.0

type Instance struct {
	// App ID.
	AppID string
	// Namespace of the app.
	Namespace string
	// Address of the instance.
	Address string
	// Dapr HTTP API port.
	DaprHTTPPort int
	// Dapr internal gRPC port (for sidecar-to-sidecar communication).
	DaprInternalPort int
	// Port the application is listening on (either HTTP or gRPC).
	AppPort int
}

Instance contains information about the instance.

type Metadata

type Metadata struct {
	metadata.Base `json:",inline"`
	Instance      Instance
	Configuration any
}

Metadata contains a name resolution specific set of metadata properties.

func (Metadata) GetPropertiesMap added in v1.13.0

func (m Metadata) GetPropertiesMap() map[string]string

GetPropertiesMap returns a map with the instance properties. This is used by components that haven't adopted the new Instance struct to receive instance information.

type ResolveRequest

type ResolveRequest struct {
	ID        string
	Namespace string
	Port      int
	Data      map[string]string
}

ResolveRequest represents service discovery resolver request.

func (ResolveRequest) CacheKey added in v1.12.9

func (r ResolveRequest) CacheKey() string

CacheKey returns a string that can be used to identify this ResolveRequest in a cache

type Resolver

type Resolver interface {
	// Init initializes name resolver.
	Init(ctx context.Context, metadata Metadata) error
	// ResolveID resolves name to address.
	ResolveID(ctx context.Context, req ResolveRequest) (string, error)
}

Resolver is the interface of name resolver.

type ResolverMulti added in v1.12.9

type ResolverMulti interface {
	ResolveIDMulti(ctx context.Context, req ResolveRequest) (AddressList, error)
}

ResolverMulti is an optional interface for name resolvers that can return multiple addresses.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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