registry

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2024 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Event

type Event struct {
}

Event struct is left empty in this example but in practice, it can be used to encapsulate details about updates to services in the registry.

type Registry

type Registry interface {
	// Register registers a new service instance with the service discovery mechanism.
	Register(ctx context.Context, si ServiceInstance) error

	// UnRegister removes an existing service instance from the service discovery mechanism.
	UnRegister(ctx context.Context, si ServiceInstance) error

	// ListServices retrieves a list of service instances by name.
	ListServices(ctx context.Context, name string) ([]ServiceInstance, error)

	// Subscribe returns a channel that emits events when the specified service updates.
	Subscribe(name string) (<-chan Event, error)

	// Closer io.Closer is embedded, meaning that the Registry can be closed, releasing any resources associated with it.
	io.Closer
}

Registry is an interface defining methods for a service discovery system.

type ServiceInstance

type ServiceInstance struct {
	Name    string // The logical name of the service instance
	Address string // The address (e.g., IP address and port) of the service instance
	Weight  uint32 // The weight of the instance, which could be used for load-balancing purposes
	Group   string // The grouping of the instance, which could be used for routing or sharding
}

ServiceInstance defines a single instance of a service that can be registered or discovered.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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