core

package
v1.0.1-0...-c918b50 Latest Latest
Warning

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

Go to latest
Published: May 4, 2021 License: MIT Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const BasePath = "/tmp/grpcox/"

BasePath define path where proto file will persisted

Variables

This section is empty.

Functions

This section is empty.

Types

type ConnStore

type ConnStore struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

ConnStore - connection store instance

func NewConnectionStore

func NewConnectionStore() *ConnStore

NewConnectionStore - constructor connection store

func (*ConnStore) StartGC

func (c *ConnStore) StartGC(interval time.Duration)

StartGC - start gc ticker

func (*ConnStore) StopGC

func (c *ConnStore) StopGC()

StopGC stops sweeping goroutine.

type GrpCox

type GrpCox struct {
	KeepAlive float64
	// contains filtered or unexported fields
}

GrpCox - main object

func InitGrpCox

func InitGrpCox() *GrpCox

InitGrpCox constructor

func (*GrpCox) CloseActiveConns

func (g *GrpCox) CloseActiveConns(host string) error

CloseActiveConns - close conn by host or all

func (*GrpCox) Extend

func (g *GrpCox) Extend(host string)

Extend extend connection based on setting max life

func (*GrpCox) GetActiveConns

func (g *GrpCox) GetActiveConns() []string

GetActiveConns - get all saved active connection

func (*GrpCox) GetKnownServers

func (g *GrpCox) GetKnownServers() []string

func (*GrpCox) GetResource

func (g *GrpCox) GetResource(ctx context.Context, target string, plainText, isRestartConn bool) (*Resource, error)

GetResource - open resource to targeted grpc server

func (*GrpCox) GetResourceWithProto

func (g *GrpCox) GetResourceWithProto(ctx context.Context, target string, plainText, isRestartConn bool, protos []Proto) (*Resource, error)

GetResourceWithProto - open resource to targeted grpc server using given protofile

type Proto

type Proto struct {
	Name    string
	Content []byte
}

Proto define protofile uploaded from client will be used to be persisted to disk and indicator whether connections should reflect from server or local proto

type Resource

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

Resource - hold 3 main function (List, Describe, and Invoke)

func (*Resource) AddProtos

func (r *Resource) AddProtos(protos []Proto) error

AddProtos to resource properties and harddisk added protos will be persisted in `basepath + connection target` i.e. connection target == 127.0.0.1:8888 proto files will be persisted in /tmp/grpcox/127.0.0.1:8888 if the directory is already there, remove it first

func (*Resource) Close

func (r *Resource) Close()

Close - to close all resources that was opened before

func (*Resource) Describe

func (r *Resource) Describe(symbol string) (string, string, error)

Describe - The "describe" verb will print the type of any symbol that the server knows about or that is found in a given protoset file. It also prints a description of that symbol, in the form of snippets of proto source. It won't necessarily be the original source that defined the element, but it will be equivalent.

func (*Resource) Invoke

func (r *Resource) Invoke(ctx context.Context, metadata []string, symbol string, in io.Reader) (string, time.Duration, error)

Invoke - invoking gRPC function

func (*Resource) List

func (r *Resource) List(symbol string) ([]string, error)

List - To list all services exposed by a server symbol can be "" to list all available services symbol also can be service name to list all available method

Jump to

Keyboard shortcuts

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