valueserver

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2020 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

* * Copyright 2020-present Arpabet Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *

Index

Constants

This section is empty.

Variables

View Source
var Any = AnyDef{}
View Source
var ErrFunctionAlreadyExist = errors.New("function already exist")
View Source
var IncomingQueueCap = 4096
View Source
var OutgoingQueueCap = 4096
View Source
var Void = VoidDef{}

Functions

func FunctionError

func FunctionError(requestId value.Number, format string, args ...interface{}) value.Map

func FunctionResult

func FunctionResult(requestId value.Number, result value.Value) value.Map

func NewServingClient

func NewServingClient(clientId int64, conn valuerpc.MsgConn, functionMap *sync.Map, logger *zap.Logger) *servingClient

func NewServingRequest

func NewServingRequest(ft functionType, requestId value.Number) *servingRequest

func StreamEnd

func StreamEnd(requestId value.Number, val value.Value) value.Map

func StreamReady

func StreamReady(requestId value.Number) value.Map

func StreamValue

func StreamValue(requestId value.Number, val value.Value) value.Map

func Verify

func Verify(args value.Value, def TypeDef) bool

func VerifyArg

func VerifyArg(arg value.Value, def ArgDef) bool

func VerifyArgs

func VerifyArgs(args value.Value, argsDef ArgsDef) bool

func VerifyParam

func VerifyParam(value value.Value, def ParamDef) bool

func VerifyParams

func VerifyParams(args value.Value, paramsDef ParamsDef) bool

Types

type AnyDef

type AnyDef struct {
}

func (AnyDef) UserTypeDef

func (t AnyDef) UserTypeDef()

type ArgDef

type ArgDef struct {
	Kind     value.Kind
	Required bool
}

func Arg

func Arg(kind value.Kind, required bool) ArgDef

func (ArgDef) UserTypeDef

func (t ArgDef) UserTypeDef()

type ArgsDef

type ArgsDef struct {
	List []ArgDef
}

func List

func List(args ...ArgDef) ArgsDef

func (ArgsDef) UserTypeDef

func (t ArgsDef) UserTypeDef()

type Chat

type Chat func(args value.Value, inC <-chan value.Value) (<-chan value.Value, error)

type Function

type Function func(args value.Value) (value.Value, error)

type IncomingStream

type IncomingStream func(args value.Value, inC <-chan value.Value) error

type OutgoingStream

type OutgoingStream func(args value.Value) (<-chan value.Value, error)

type ParamDef

type ParamDef struct {
	Name     string
	Kind     value.Kind
	Required bool
}

func Param

func Param(name string, kind value.Kind, required bool) ParamDef

type ParamsDef

type ParamsDef struct {
	Map []ParamDef
}

func Map

func Map(params ...ParamDef) ParamsDef

func (ParamsDef) UserTypeDef

func (t ParamsDef) UserTypeDef()

type Server

type Server interface {
	AddFunction(name string, args TypeDef, res TypeDef, cb Function) error

	// GET for client
	AddOutgoingStream(name string, args TypeDef, cb OutgoingStream) error

	// PUT for client
	AddIncomingStream(name string, args TypeDef, cb IncomingStream) error

	// Dual channel chat
	AddChat(name string, args TypeDef, cb Chat) error

	Run() error

	Close() error
}

func NewDevelopmentServer

func NewDevelopmentServer(address string) (Server, error)

func NewServer

func NewServer(address string, logger *zap.Logger) (Server, error)

type TypeDef

type TypeDef interface {
	UserTypeDef()
}

type VoidDef

type VoidDef struct {
}

func (VoidDef) UserTypeDef

func (t VoidDef) UserTypeDef()

Jump to

Keyboard shortcuts

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