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

discovery

package
v1.0.246 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GCEDiscoverer

type GCEDiscoverer struct {
	ProjectID string // GCP project ID
	Zone      string // GCE zone (e.g., "us-central1-a")
	SelfName  string // this instance's name (excluded from results)
	Tag       string // instance tag to filter by (e.g., "gluon-ion")

	// HTTPClient is an optional HTTP client for making API calls.
	// If nil, a default client is used. Useful for testing.
	HTTPClient *http.Client

	// TokenURL overrides the metadata server URL for fetching access tokens.
	// Defaults to the GCE metadata server. Useful for testing.
	TokenURL string

	// BaseURL overrides the Compute API base URL.
	// Defaults to https://compute.googleapis.com. Useful for testing.
	BaseURL string
}

GCEDiscoverer discovers peers by listing GCE instances with a specific tag. Uses workload identity for authentication (no explicit credentials).

It calls the GCE compute REST API directly using the metadata server for authentication, avoiding the heavy google.golang.org/api dependency.

func (*GCEDiscoverer) Discover

func (g *GCEDiscoverer) Discover(ctx context.Context) ([]string, error)

Discover lists GCE instances matching the configured tag, excludes self, and returns the internal IPs of running instances.

func (*GCEDiscoverer) Name

func (g *GCEDiscoverer) Name() string

Name returns "gce".

type PeerDiscoverer

type PeerDiscoverer interface {
	// Discover returns peer addresses (host:port or just host).
	Discover(ctx context.Context) ([]string, error)
	// Name returns a human-readable discoverer name for logging.
	Name() string
}

PeerDiscoverer discovers memberlist peer addresses for Gravity cluster formation.

type StaticDiscoverer

type StaticDiscoverer struct {
	Peers []string
}

StaticDiscoverer returns a fixed set of peer addresses. Useful for development, testing, and environments with known IPs.

func (*StaticDiscoverer) Discover

func (s *StaticDiscoverer) Discover(_ context.Context) ([]string, error)

Discover returns the configured peer addresses.

func (*StaticDiscoverer) Name

func (s *StaticDiscoverer) Name() string

Name returns "static".

Jump to

Keyboard shortcuts

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