memory

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2018 License: Apache-2.0 Imports: 7 Imported by: 0

README

Memory Registry

In-memory registry can be used where no coordination or third party dependency is required.

Usage

### With Flag

import _ "github.com/micro/go-plugins/registry/memory"
go run main.go --registry=memory
Direct Use
import (
	"github.com/micro/go-micro"
	"github.com/micro/go-plugins/registry/memory"
)

func main() {
	service := micro.NewService(
		micro.Name("my.service"),
		micro.Registry(memory.NewRegistry()),
	)
}

### Preload Services

import (
	"github.com/micro/go-micro"
	"github.com/micro/go-micro/registry"
	"github.com/micro/go-plugins/registry/memory"
)

func main() {
	// list of services
	services := map[string][]*registry.Service{
		"srv.foo": []*registry.Service{
			&registry.Service{
				Name: "srv.foo",
				Version: "latest",
				Nodes: []*registry.Node{
					&registry.Node{
						Id: "srv.foo.1",
						Address: "10.0.0.1",
						Port: 10001,
					},
				},
			}
		},
	}

	// create registry
	r := memory.NewRegistry(
		memory.Services(services),
	)

	service := micro.NewService(
		micro.Name("my.service"),
		micro.Registry(r),
	)
}

Documentation

Overview

Package memory provides an in-memory registry

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewRegistry

func NewRegistry(opts ...registry.Option) registry.Registry

func Services

func Services(s map[string][]*registry.Service) registry.Option

Services is an option that preloads service data

Types

This section is empty.

Jump to

Keyboard shortcuts

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