📅 You're Invited: Meet the Socket team at RSAC (April 28 – May 1).RSVP
Socket
Sign inDemoInstall
Socket

github.com/xialeistudio/go-service-discovery

Package Overview
Dependencies
Alerts
File Explorer
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/xialeistudio/go-service-discovery

v0.0.4
Source
Go
Version published
Created
Source

go-service-discovery

中文文档

A Go-based microservices discovery toolkit designed for modern cloud-native applications. It provides a robust framework for service registration, discovery, and monitoring, leveraging the power of etcd for distributed coordination.

Features

  • Service Registration and Discovery: Register and discover microservices using a centralized registry.
  • Load Balancing: Offers built-in load balancing strategies including round-robin and random selection, etc.
  • Tag-based Discovery: Allows services to be discovered based on tags for more granular control.
  • Watch Mechanism: Watches for changes in service instances and updates the local cache accordingly.

Supporting platforms

  • etcd v3.x
  • consul
  • zookeeper

Get Started

The following code uses etcd as an example to demonstrate how to use it.

r, err := NewRegistry([]string{"localhost:2379"})
if err != nil {
    log.Fatalf("failed to create registry: %v", err)
}
// Register a service node
err = r.Register(context.Background(), node)
// Unregister a service node
err = r.Unregister(context.Background(), node)
// Discover a service node
nodes, err := r.Discover(context.Background(), "service-name", map[string]string{
	// tags
})

FAQs

Package last updated on 17 Sep 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts