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

nameformat

package
v1.19.0 Latest Latest
Warning

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

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

README

Name Format Name Resolution

The Name Format name resolver provides a flexible way to resolve service names using a configurable format string with placeholders. This is useful in scenarios where you want to map service names to predictable DNS names following a specific pattern.

Configuration Format

To use the Name Format name resolver, create a configuration in your Dapr environment:

apiVersion: dapr.io/v1alpha1
kind: Configuration
metadata:
  name: appconfig
spec:
  nameResolution:
    component: "nameformat"
    configuration:
      format: "service-{appid}.default.svc.cluster.local"  # Replace with your desired format pattern

Configuration Fields

Field Required Details Example
format Y The format string to use for name resolution. Must contain the {appid} placeholder which will be replaced with the actual service name. "service-{appid}.default.svc.cluster.local"

Examples

When configured with format: "service-{appid}.default.svc.cluster.local", the resolver will transform service names as follows:

  • Service ID "myapp" → "service-myapp.default.svc.cluster.local"
  • Service ID "frontend" → "service-frontend.default.svc.cluster.local"

Notes

  • Empty service IDs are not allowed and will result in an error
  • The format string must be provided in the configuration
  • The format string must contain at least one {appid} placeholder

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewResolver

func NewResolver(logger logger.Logger) nr.Resolver

NewResolver creates a new Name Format resolver.

Types

type NameFormatResolver

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

NameFormatResolver implements a name resolution component that formats service names according to a configurable pattern.

func (*NameFormatResolver) Close

func (r *NameFormatResolver) Close() error

Close implements io.Closer

func (*NameFormatResolver) GetComponentMetadata

func (r *NameFormatResolver) GetComponentMetadata() metadata.MetadataMap

GetComponentMetadata returns the metadata information for the component.

func (*NameFormatResolver) Init

func (r *NameFormatResolver) Init(ctx context.Context, metadata nr.Metadata) error

Init initializes the name format resolver with the given metadata.

func (*NameFormatResolver) ResolveID

func (r *NameFormatResolver) ResolveID(ctx context.Context, req nr.ResolveRequest) (string, error)

ResolveID resolves a service ID to an address using the configured format.

Jump to

Keyboard shortcuts

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