client

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

SPDX-License-Identifier: MIT SPDX-FileCopyrightText: 2023 werbenhu SPDX-FileContributor: werbenhu

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type RpcClient

type RpcClient struct {
	// Addr is the registry server address.
	Addr string
	// contains filtered or unexported fields
}

RpcClient is a gRPC client for service discovery.

func NewRpcClient

func NewRpcClient(addr string) (*RpcClient, error)

NewRpcClient creates a new RpcClient object and connects to the registry server at `addr`.

func (*RpcClient) Close

func (c *RpcClient) Close()

Close closes the gRPC client connection.

func (*RpcClient) Match

func (c *RpcClient) Match(group string, key string) (*registry.Service, error)

Match assigns a service to a key using the consistent hashing algorithm.

Parameters: - group: The group name of the services. - key: The key, such as user ID, device ID, etc.

Returns: - The service that matches the key. - An error if the service cannot be found.

func (*RpcClient) Members

func (c *RpcClient) Members(group string) ([]*registry.Service, error)

Members returns the list of services in a group.

Parameters: - group: The group name of the services.

Returns: - The list of services in the group. - An error if the group does not exist or cannot be accessed.

Jump to

Keyboard shortcuts

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