polaris

package module
v0.0.0-...-f8d5985 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2023 License: MIT Imports: 20 Imported by: 0

README

Quick Start

Prerequisites:

Download the module:

go get -u github.com/zeromicro/zero-contrib/zrpc/registry/polaris

For example:

Service

  • ./polaris.yaml
global:
  serverConnector:
    addresses:
      - 127.0.0.1:8091
  • main.go
import _ "github.com/zeromicro/zero-contrib/zrpc/registry/polaris"

func main() {
	flag.Parse()

	var c config.Config
	conf.MustLoad(*configFile, &c)

	server := zrpc.MustNewServer(c.RpcServerConf, func(grpcServer *grpc.Server) {

	})
	// register service to polaris
    opts := polaris.NewPolarisConfig(c.ListenOn)
	opts.ServiceName = "EchoServerZero" 
	opts.Namespace = "default"
	opts.ServiceToken = "2af8fdf2534f451e8f01881d1b66f9ec"
    _ = polaris.RegisterService(opts)

	server.Start()
}

Client

  • main.go
import _ "github.com/zeromicro/zero-contrib/zrpc/registry/polaris"
  • etc/*.yaml
# polaris://[user:passwd]@host/service?param=value'
Target: polaris://127.0.0.1:8091/EchoServerZero?wait=14s

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterService

func RegisterService(opts *Options) error

RegisterService register service to polaris

Types

type Option

type Option func(*Options)

func WithHeartbeatInervalSec

func WithHeartbeatInervalSec(heartbeatInervalSec int) Option

func WithMetadata

func WithMetadata(metadata map[string]string) Option

func WithNamespace

func WithNamespace(namespace string) Option

func WithProtocol

func WithProtocol(protocol string) Option

func WithServiceName

func WithServiceName(serviceName string) Option

func WithVersion

func WithVersion(version string) Option

func WithWeight

func WithWeight(weight float64) Option

type Options

type Options struct {
	ListenOn            string
	Namespace           string
	ServiceToken        string
	ServiceName         string
	Weight              float64
	Protocol            string
	Version             string
	HeartbeatInervalSec int
	Metadata            map[string]string
}

options

func NewPolarisConfig

func NewPolarisConfig(listenOn string, opts ...Option) *Options

Jump to

Keyboard shortcuts

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