server

package
v1.1.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 rpc.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 added in v1.1.0

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

func VerifyArg added in v1.1.0

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

func VerifyArgs added in v1.1.0

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

func VerifyParam added in v1.1.0

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

func VerifyParams added in v1.1.0

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

Types

type AnyDef added in v1.1.0

type AnyDef struct {
}

func (AnyDef) UserTypeDef added in v1.1.0

func (t AnyDef) UserTypeDef()

type ArgDef added in v1.1.0

type ArgDef struct {
	Kind     value.Kind
	Required bool
}

func Arg added in v1.1.0

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

func (ArgDef) UserTypeDef added in v1.1.0

func (t ArgDef) UserTypeDef()

type ArgsDef added in v1.1.0

type ArgsDef struct {
	List []ArgDef
}

func List added in v1.1.0

func List(args ...ArgDef) ArgsDef

func (ArgsDef) UserTypeDef added in v1.1.0

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 added in v1.1.0

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

func Param added in v1.1.0

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

type ParamsDef added in v1.1.0

type ParamsDef struct {
	Map []ParamDef
}

func Map added in v1.1.0

func Map(params ...ParamDef) ParamsDef

func (ParamsDef) UserTypeDef added in v1.1.0

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 added in v1.1.0

type TypeDef interface {
	UserTypeDef()
}

type VoidDef added in v1.1.0

type VoidDef struct {
}

func (VoidDef) UserTypeDef added in v1.1.0

func (t VoidDef) UserTypeDef()

Jump to

Keyboard shortcuts

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