provider

package
v0.7.1 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2018 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InstallProviderPlugin

func InstallProviderPlugin(pluginName string, newFunc func(string) Provider)

InstallProviderPlugin install provider plugin

func RegisterCustomProvider

func RegisterCustomProvider(microserviceName string, p Provider)

RegisterCustomProvider register customer provider

func RegisterSchema

func RegisterSchema(microserviceName string, schema interface{}) (string, error)

RegisterSchema register schema

func RegisterSchemaWithName

func RegisterSchemaWithName(microserviceName string, schemaID string, schema interface{}) error

RegisterSchemaWithName register schema with name

Types

type DefaultProvider

type DefaultProvider struct {
	MicroServiceName string
	SchemaMap        map[string]*Schema //string=schemaID
	OperationMap     map[string]*operation
	// contains filtered or unexported fields
}

DefaultProvider default provider

func (*DefaultProvider) Exist

func (p *DefaultProvider) Exist(schemaID string, operationID string) bool

Exist check the schema, operation is present or not

func (*DefaultProvider) GetOperation

func (p *DefaultProvider) GetOperation(schemaID string, operationID string) (Operation, error)

GetOperation get operation

func (*DefaultProvider) Invoke

func (p *DefaultProvider) Invoke(inv *invocation.Invocation) (interface{}, error)

Invoke is for to invoke the methods of defaultprovider

func (*DefaultProvider) Register

func (p *DefaultProvider) Register(schema interface{}) (string, error)

Register publishes in the server the set of methods of the receiver value that satisfy the following conditions:

  • exported method of exported type
  • two arguments, both of exported type
  • the second argument is a pointer
  • one return value, of type error

It returns an error if the receiver is not an exported type or has no suitable methods. It also logs the error using package log. The client accesses each method using a string of the form "Type.Method", where Type is the receiver's concrete type.

func (*DefaultProvider) RegisterName

func (p *DefaultProvider) RegisterName(name string, rcvr interface{}) error

RegisterName is like Register but uses the provided name for the type instead of the receiver's concrete type.

type Operation

type Operation interface {
	Method() reflect.Method
	Args() []reflect.Type
	Reply() []reflect.Type
}

Operation is the interface for schema parameters

func GetOperation

func GetOperation(microserviceName string, schemaID string, operationID string) (Operation, error)

GetOperation get operation

type Provider

type Provider interface {
	//Register a schema
	Register(schema interface{}) (string, error)
	RegisterName(name string, schema interface{}) error
	//invoke schema function
	Invoke(inv *invocation.Invocation) (interface{}, error)
	GetOperation(schemaID string, operationID string) (Operation, error)
	//if exists in local,for localcall
	Exist(schemaID, operationID string) bool
}

Provider is the interface for schema methods

func GetProvider

func GetProvider(microserviceName string) (Provider, error)

GetProvider get provider

func NewProvider

func NewProvider(microserviceName string) Provider

NewProvider returns the object of DefaultProvider

func RegisterProvider

func RegisterProvider(pluginName string, microserviceName string) Provider

RegisterProvider register provider

type Schema

type Schema struct {
	// contains filtered or unexported fields
}

Schema struct is having schema name, receiver, and registered methods

Jump to

Keyboard shortcuts

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