client

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2025 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PostgresDiscovery

type PostgresDiscovery struct {

	// -1 means it always retry to watch until postgres is ok, 0 means no retry.
	RetriesAfterWatchFailed int
	// contains filtered or unexported fields
}

PostgresDiscovery is a PostgreSQL-based service discovery. It accepts an external connection pool and watches for service updates.

func NewPostgresDiscoveryWithPool

func NewPostgresDiscoveryWithPool(ctx context.Context, serviceAddress, servicePath string, pool *pgxpool.Pool, opt *PostgresDiscoveryOption) (*PostgresDiscovery, error)

NewPostgresDiscoveryWithPool returns a new PostgresDiscovery using an existing pool.

func (*PostgresDiscovery) Clone

func (d *PostgresDiscovery) Clone(servicePath string) (client.ServiceDiscovery, error)

Clone clones this ServiceDiscovery with new servicePath

func (*PostgresDiscovery) Close

func (d *PostgresDiscovery) Close()

Close closes the discovery but not the underlying pool

func (*PostgresDiscovery) GetServices

func (d *PostgresDiscovery) GetServices() []*client.KVPair

GetServices returns the servers

func (*PostgresDiscovery) RemoveWatcher

func (d *PostgresDiscovery) RemoveWatcher(ch chan []*client.KVPair)

func (*PostgresDiscovery) SetFilter

func (d *PostgresDiscovery) SetFilter(filter client.ServiceDiscoveryFilter)

SetFilter sets the filter

func (*PostgresDiscovery) WatchService

func (d *PostgresDiscovery) WatchService() chan []*client.KVPair

WatchService returns a channel to watch for changes

type PostgresDiscoveryOption

type PostgresDiscoveryOption struct {
	// RetryCount for watch failures. -1 means infinite retries
	RetryCount int
	// Filter for filtering services
	Filter client.ServiceDiscoveryFilter
	// Table for storing services
	Table string
}

PostgresDiscoveryOption represents options for PostgresDiscovery

type ServiceChange

type ServiceChange struct {
	Operation      string `json:"operation"`
	ServicePath    string `json:"service_path"`
	ServiceAddress string `json:"service_address"`
	Meta           string `json:"meta"`
}

Jump to

Keyboard shortcuts

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