turbo

package module
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2023 License: MIT Imports: 34 Imported by: 5

README

Turbo  Build Status Coverage Status Go Report Card codebeat badge

最新版本 | Latest Release: 0.5.0

文档地址 | Documentation: https://vaporz.github.io


I'm very happy and ready to help you if you're intersted in Turbo, and want to try it.
Please create an issue if you have encountered any problems or have any new ideas. Thank you!
如果你对Turbo感兴趣,并想试一试,我非常乐意帮助你。
如遇到任何问题,或有新主意,请开issue,谢谢!
(From movie "Turbo")

Features

  • Turbo generates a reverse-proxy server which translates a HTTP request into a grpc/Thrift request.
    (In other words, now you have a grpc|thrift service? Turbo turns your grpc|thrift APIs into HTTP APIs!)
  • Modify and reload configuration file at runtime! Without restarting service.
  • Support gRPC and Thrift.
  • Support RESTFUL JSON API ("application/json").
  • Interceptor.
  • PreProcessor and PostProcessor: customizable URL-RPC mapping process.
  • Hijacker: Take over requests, do anything you want!
  • Convertor: Tell Turbo how to set a struct.
  • Service Multiplexing

Index

Requirements

Golang version: >= 1.21.3

Thrift version: 0.19.0

Documentation

Overview

* Copyright © 2017 Xiao Zhang <zzxx513@gmail.com>. * Use of this source code is governed by an MIT-style * license that can be found in the LICENSE file.

* Copyright © 2017 Xiao Zhang <zzxx513@gmail.com>. * Use of this source code is governed by an MIT-style * license that can be found in the LICENSE file.

* Copyright © 2017 Xiao Zhang <zzxx513@gmail.com>. * Use of this source code is governed by an MIT-style * license that can be found in the LICENSE file.

* Copyright © 2017 Xiao Zhang <zzxx513@gmail.com>. * Use of this source code is governed by an MIT-style * license that can be found in the LICENSE file.

* Copyright © 2017 Xiao Zhang <zzxx513@gmail.com>. * Use of this source code is governed by an MIT-style * license that can be found in the LICENSE file.

* Copyright © 2017 Xiao Zhang <zzxx513@gmail.com>. * Use of this source code is governed by an MIT-style * license that can be found in the LICENSE file.

* Copyright © 2017 Xiao Zhang <zzxx513@gmail.com>. * Use of this source code is governed by an MIT-style * license that can be found in the LICENSE file.

* Copyright © 2017 Xiao Zhang <zzxx513@gmail.com>. * Use of this source code is governed by an MIT-style * license that can be found in the LICENSE file.

* Copyright © 2017 Xiao Zhang <zzxx513@gmail.com>. * Use of this source code is governed by an MIT-style * license that can be found in the LICENSE file.

* Copyright © 2017 Xiao Zhang <zzxx513@gmail.com>. * Use of this source code is governed by an MIT-style * license that can be found in the LICENSE file.

* Copyright © 2017 Xiao Zhang <zzxx513@gmail.com>. * Use of this source code is governed by an MIT-style * license that can be found in the LICENSE file.

* Copyright © 2017 Xiao Zhang <zzxx513@gmail.com>. * Use of this source code is governed by an MIT-style * license that can be found in the LICENSE file.

Index

Constants

This section is empty.

Variables

View Source
var CallOptions = func(serviceName, methodName string, req *http.Request) ([]grpc.CallOption, *metadata.MD, *metadata.MD, *peer.Peer) {
	header := new(metadata.MD)
	trailer := new(metadata.MD)
	peer := &peer.Peer{}
	callOptions := []grpc.CallOption{
		grpc.Header(header),
		grpc.Trailer(trailer),
		grpc.Peer(peer),
	}
	return callOptions, header, trailer, peer
}

CallOptions returns grpc CallOptions, you can overwrite this func to build CallOptions for your needs.

View Source
var File_testprotos_proto protoreflect.FileDescriptor
View Source
var RpcType string

RpcType should be "grpc" or "thrift"

Functions

func BuildArgs

func BuildArgs(s Servable, argsType reflect.Type, argsValue reflect.Value, req *http.Request, buildStructArg func(s Servable, typeName string, req *http.Request) (v reflect.Value, err error)) ([]reflect.Value, error)

BuildArgs returns a list of reflect.Value for thrift request

func BuildRequest

func BuildRequest(s Servable, v proto.Message, req *http.Request) error

func BuildStruct

func BuildStruct(s Servable, theType reflect.Type, theValue reflect.Value, req *http.Request)

BuildStruct finds values from request, and set them to struct fields recursively

func BuildThriftRequest

func BuildThriftRequest(s Servable, args interface{}, req *http.Request, buildStructArg func(s Servable, typeName string, req *http.Request) (v reflect.Value, err error)) ([]reflect.Value, error)

func GetWD added in v0.4.0

func GetWD() string

func GrpcMetadataHeader

func GrpcMetadataHeader(ctx context.Context) *metadata.MD

GrpcMetadataHeader returns the header in metadata

func GrpcMetadataPeer

func GrpcMetadataPeer(ctx context.Context) *peer.Peer

GrpcMetadataPeer returns the peer in metadata

func GrpcMetadataTrailer

func GrpcMetadataTrailer(ctx context.Context) *metadata.MD

GrpcMetadataTrailer returns the trailer in metadata

func IsCamelCase

func IsCamelCase(name string) bool

IsCamelCase returns true if name is a CamelCase string

func IsNotCamelCase

func IsNotCamelCase(name string) bool

IsNotCamelCase returns true if name is not a CamelCase string

func SetOutput

func SetOutput(out io.Writer)

SetOutput sets output at runtime

func ToSnakeCase

func ToSnakeCase(str string) string

ToSnakeCase convert a camelCase string into a snake_case string

func WithCallOptions

func WithCallOptions(req *http.Request, header *metadata.MD, trailer *metadata.MD, peer *peer.Peer)

WithCallOptions read header, trailer and peer into context

Types

type BaseInterceptor

type BaseInterceptor struct{}

BaseInterceptor implements an empty Before() and After()

func (*BaseInterceptor) After

func (i *BaseInterceptor) After(resp http.ResponseWriter, req *http.Request) error

After will run after a request performs

func (*BaseInterceptor) Before

func (i *BaseInterceptor) Before(resp http.ResponseWriter, req *http.Request) error

Before will run before a request performs

type Components

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

Components holds all component mappings

func (*Components) CommonInterceptors

func (c *Components) CommonInterceptors() []Interceptor

CommonInterceptors returns a list of Interceptors which are default

func (*Components) Convertor

func (c *Components) Convertor(theType string) Convertor

Convertor returns the Convertor for this type

func (*Components) Hijacker

func (c *Components) Hijacker(req *http.Request) Hijacker

Hijacker returns a Hijacker for this request

func (*Components) Intercept

func (c *Components) Intercept(methods []string, urlPattern string, list ...Interceptor)

Intercept registers a list of Interceptors to an URL pattern at given HTTP methods

func (*Components) Interceptors

func (c *Components) Interceptors(req *http.Request) Interceptors

Interceptors returns a list of Interceptors for this request

func (*Components) Postprocessor

func (c *Components) Postprocessor(req *http.Request) Postprocessor

Postprocessor returns a Postprocessor for this request

func (*Components) Preprocessor

func (c *Components) Preprocessor(req *http.Request) Preprocessor

Preprocessor returns a preprocessor for this request

func (*Components) Reset

func (c *Components) Reset()

Reset resets all component mappings

func (*Components) SetCommonInterceptor

func (c *Components) SetCommonInterceptor(interceptors ...Interceptor)

SetCommonInterceptor assigns Interceptors to all URLs, if the URL has no other Interceptors assigned

func (*Components) SetConvertor

func (c *Components) SetConvertor(field string, convertorFunc Convertor)

SetConvertor registers a Convertor on a type usage: SetConvertor(new(SomeInterface), convertorFunc)

func (*Components) SetHijacker

func (c *Components) SetHijacker(methods []string, urlPattern string, h Hijacker)

SetHijacker registers a Hijacker to an URL pattern

func (*Components) SetPostprocessor

func (c *Components) SetPostprocessor(methods []string, urlPattern string, post Postprocessor)

SetPostprocessor registers a Postprocessor to an URL pattern

func (*Components) SetPreprocessor

func (c *Components) SetPreprocessor(methods []string, urlPattern string, pre Preprocessor)

SetPreprocessor registers a preprocessor to an URL pattern

func (*Components) WithErrorHandler

func (c *Components) WithErrorHandler(e ErrorHandlerFunc)

WithErrorHandler registers an errorHandler to handle errors

type Config

type Config struct {
	viper.Viper
	// File is the config file path
	File string
	// contains filtered or unexported fields
}

Config holds the info in a config file

func NewConfig

func NewConfig(rpcType, configFilePath string) *Config

NewConfig loads the config file at 'configFilePath', and returns a Config struct ptr

func (*Config) Env

func (c *Config) Env() string

func (*Config) ErrorHandler

func (c *Config) ErrorHandler() string

func (*Config) FileRootPath added in v0.4.0

func (c *Config) FileRootPath() string

FileRootPath returns the absolute path to the root of packages,

func (*Config) FilterProtoJson

func (c *Config) FilterProtoJson() bool

func (*Config) FilterProtoJsonEmitZeroValues

func (c *Config) FilterProtoJsonEmitZeroValues() bool

func (*Config) FilterProtoJsonInt64AsNumber

func (c *Config) FilterProtoJsonInt64AsNumber() bool

func (*Config) GrpcServiceHost

func (c *Config) GrpcServiceHost() string

func (*Config) GrpcServiceNames

func (c *Config) GrpcServiceNames() []string

func (*Config) GrpcServicePort

func (c *Config) GrpcServicePort() string

func (*Config) HTTPPort

func (c *Config) HTTPPort() int64

func (*Config) PackagePath added in v0.4.0

func (c *Config) PackagePath() string

PackagePath returns the base package name,

func (*Config) ServiceRootPath

func (c *Config) ServiceRootPath() string

ServiceRootPath returns the absolute path to service's root,

func (*Config) ThriftServiceHost

func (c *Config) ThriftServiceHost() string

func (*Config) ThriftServiceNames

func (c *Config) ThriftServiceNames() []string

func (*Config) ThriftServicePort

func (c *Config) ThriftServicePort() string

type ContextHook

type ContextHook struct{}

ContextHook is a hook to be fired when logging on the logging levels returned from `Levels()` on your implementation of the interface. Note that this is not fired in a goroutine or a channel with workers, you should handle such functionality yourself if your call is non-blocking and you don't wish for the logging calls for levels returned from `Levels()` to block.

The original hook interface is:

type Hook interface {
	 Levels() []Level
	 Fire(*Entry) error
}

func (ContextHook) Fire

func (hook ContextHook) Fire(entry *logger.Entry) error

Fire is for adding file, func and line info to logger.

func (ContextHook) Levels

func (hook ContextHook) Levels() []logger.Level

Levels returns active log levels

type Convertor

type Convertor func(r *http.Request) reflect.Value

Convertor--------------

type Creator

type Creator struct {
	RpcType      string
	PkgPath      string
	FileRootPath string
	// contains filtered or unexported fields
}

Creator creates new projects

func (*Creator) CreateProject

func (c *Creator) CreateProject(serviceName string, force bool)

CreateProject creates a whole new project!

type ErrorHandlerFunc

type ErrorHandlerFunc func(http.ResponseWriter, *http.Request, error)

ErrorHandler----------

type Generator

type Generator struct {
	RpcType        string
	PkgPath        string
	ConfigFileName string
	Options        string

	FilePaths []string
	// contains filtered or unexported fields
}

Generator generates proto/thrift code

func (*Generator) Generate

func (g *Generator) Generate()

Generate proto/thrift code

func (*Generator) GenerateBuildThriftParameters

func (g *Generator) GenerateBuildThriftParameters()

GenerateBuildThriftParameters generates "build.go"

func (*Generator) GenerateGrpcSwitcher

func (g *Generator) GenerateGrpcSwitcher()

GenerateGrpcSwitcher generates "grpcswither.go"

func (*Generator) GenerateProtobufStub

func (g *Generator) GenerateProtobufStub()

GenerateProtobufStub generates protobuf stub codes

func (*Generator) GenerateThriftStub

func (g *Generator) GenerateThriftStub()

GenerateThriftStub generates Thrift stub codes

func (*Generator) GenerateThriftSwitcher

func (g *Generator) GenerateThriftSwitcher()

GenerateThriftSwitcher generates "thriftswitcher.go"

type GrpcServer

type GrpcServer struct {
	*Server
	// contains filtered or unexported fields
}

func NewGrpcServer

func NewGrpcServer(initializer Initializable, configFilePath string) *GrpcServer

func (*GrpcServer) ServerField

func (s *GrpcServer) ServerField() *Server

func (*GrpcServer) Service

func (s *GrpcServer) Service(serviceName string) interface{}

GrpcService returns a grpc client instance, example: client := turbo.GrpcService().(proto.YourServiceClient)

func (*GrpcServer) Start

func (s *GrpcServer) Start(clientCreator grpcClientCreator, sw switcher, registerServer func(s *grpc.Server))

Start starts both HTTP server and GRPC service

func (*GrpcServer) StartGrpcService

func (s *GrpcServer) StartGrpcService(registerServer func(s *grpc.Server))

StartGrpcService starts a GRPC service

func (*GrpcServer) StartHTTPServer

func (s *GrpcServer) StartHTTPServer(clientCreator grpcClientCreator, sw switcher)

StartHTTPServer starts a HTTP server which sends requests via grpc

func (*GrpcServer) Stop

func (s *GrpcServer) Stop()

type Hijacker

type Hijacker func(http.ResponseWriter, *http.Request)

Hijacker-----------------

func (Hijacker) ServeHTTP

func (h Hijacker) ServeHTTP(http.ResponseWriter, *http.Request)

ServeHTTP is an empty func, only for implementing http.Handler

type Initializable

type Initializable interface {
	// InitService is run before the service is started, do initializing staffs for your service here
	InitService(s Servable) error

	// StopService is run after both grpc server and http server are stopped,
	// do your cleaning up work here.
	StopService(s Servable)
}

Initializable defines funcs run before service started and after service stopped

type Interceptor

type Interceptor interface {
	Before(http.ResponseWriter, *http.Request) error
	After(http.ResponseWriter, *http.Request) error
}

Interceptor intercepts requests, can run a func before and after a request

type Interceptors

type Interceptors []Interceptor

func (Interceptors) ServeHTTP

func (i Interceptors) ServeHTTP(http.ResponseWriter, *http.Request)

ServeHTTP is an empty func, only for implementing http.Handler

type Marshaler

type Marshaler struct {
	FilterProtoJson bool
	EmitZeroValues  bool
	Int64AsNumber   bool
}

Marshaler marshals a struct to JSON

func (*Marshaler) FilterJsonWithStruct

func (m *Marshaler) FilterJsonWithStruct(jsonBytes []byte, structObj interface{}) (bytes []byte, e error)

FilterJsonWithStruct walks through a struct, comparing each struct field with the key which have same name('fieldName'=='field_name') in json, and change the json by: 1, if struct field type is 'int64', then change the value in Json into a number 2, if field type is 'Ptr', and field value is 'nil', then set "[key_name]":null in Json 3, if any key in json is missing, set zero value to that key The reason why we do this is (a) protobuf parse int64 as string, (b) a Key with a nil Ptr value is missing in the json marshaled by github.com/golang/protobuf/jsonpb.Marshaler So, this func is a 'patch' to protobuf

func (*Marshaler) JSON

func (m *Marshaler) JSON(v interface{}) ([]byte, error)

JSON returns the json encoding of v, if v implements 'proto.Message', then FilterJsonWithStruct() is called, see comments for FilterJsonWithStruct(), otherwise, call encoding/json.Marshal()

type Postprocessor

type Postprocessor func(http.ResponseWriter, *http.Request, interface{}, error) error

PostProcessor--------------

func (Postprocessor) ServeHTTP

func (p Postprocessor) ServeHTTP(http.ResponseWriter, *http.Request)

ServeHTTP is an empty func, only for implementing http.Handler

type Preprocessor

type Preprocessor func(http.ResponseWriter, *http.Request) error

PreProcessor-------------

func (Preprocessor) ServeHTTP

func (p Preprocessor) ServeHTTP(http.ResponseWriter, *http.Request)

ServeHTTP is an empty func, only for implementing http.Handler

type Servable

type Servable interface {
	Service(serviceName string) interface{}
	ServerField() *Server
	Stop()
	RegisterComponent(name string, component interface{})
}

type Server

type Server struct {
	// Config holds data read from config file
	Config *Config
	// Components holds the mappings of url to component
	Components *Components

	// Initializer implements Initializable
	Initializer Initializable
	// contains filtered or unexported fields
}

Server holds the data for a server

func (*Server) Component

func (s *Server) Component(name string) (interface{}, error)

Component returns a component by name.

func (*Server) RegisterComponent

func (s *Server) RegisterComponent(name string, component interface{})

RegisterComponent registers a component, The convention is to register with the name of that component, the name is used in config file to look up for a component.

func (*Server) ServerField

func (s *Server) ServerField() *Server

func (*Server) Service

func (s *Server) Service() interface{}

func (*Server) Stop

func (s *Server) Stop()

Stop stops the server gracefully

type TestPrimitives added in v0.4.0

type TestPrimitives struct {
	Int64Value   int64   `protobuf:"varint,1,opt,name=Int64Value,json=int64Value,proto3" json:"Int64Value,omitempty"`
	Int32Value   int32   `protobuf:"zigzag32,2,opt,name=Int32Value,json=int32Value,proto3" json:"Int32Value,omitempty"`
	Uint64Value  uint64  `protobuf:"varint,3,opt,name=Uint64Value,json=uint64Value,proto3" json:"Uint64Value,omitempty"`
	Uint32Value  uint32  `protobuf:"varint,4,opt,name=Uint32Value,json=uint32Value,proto3" json:"Uint32Value,omitempty"`
	Float32Value float32 `protobuf:"fixed32,5,opt,name=Float32Value,json=float32Value,proto3" json:"Float32Value,omitempty"`
	Float64Value float64 `protobuf:"fixed64,6,opt,name=Float64Value,json=float64Value,proto3" json:"Float64Value,omitempty"`
	BoolValue    bool    `protobuf:"varint,7,opt,name=BoolValue,json=boolValue,proto3" json:"BoolValue,omitempty"`
	// contains filtered or unexported fields
}

func (*TestPrimitives) Descriptor deprecated added in v0.4.0

func (*TestPrimitives) Descriptor() ([]byte, []int)

Deprecated: Use TestPrimitives.ProtoReflect.Descriptor instead.

func (*TestPrimitives) GetBoolValue added in v0.4.0

func (x *TestPrimitives) GetBoolValue() bool

func (*TestPrimitives) GetFloat32Value added in v0.4.0

func (x *TestPrimitives) GetFloat32Value() float32

func (*TestPrimitives) GetFloat64Value added in v0.4.0

func (x *TestPrimitives) GetFloat64Value() float64

func (*TestPrimitives) GetInt32Value added in v0.4.0

func (x *TestPrimitives) GetInt32Value() int32

func (*TestPrimitives) GetInt64Value added in v0.4.0

func (x *TestPrimitives) GetInt64Value() int64

func (*TestPrimitives) GetUint32Value added in v0.4.0

func (x *TestPrimitives) GetUint32Value() uint32

func (*TestPrimitives) GetUint64Value added in v0.4.0

func (x *TestPrimitives) GetUint64Value() uint64

func (*TestPrimitives) ProtoMessage added in v0.4.0

func (*TestPrimitives) ProtoMessage()

func (*TestPrimitives) ProtoReflect added in v0.4.0

func (x *TestPrimitives) ProtoReflect() protoreflect.Message

func (*TestPrimitives) Reset added in v0.4.0

func (x *TestPrimitives) Reset()

func (*TestPrimitives) String added in v0.4.0

func (x *TestPrimitives) String() string

type TestProtoStruct added in v0.4.0

type TestProtoStruct struct {
	Value int64 `protobuf:"varint,1,opt,name=Value,json=value,proto3" json:"Value,omitempty"`
	// contains filtered or unexported fields
}

func (*TestProtoStruct) Descriptor deprecated added in v0.4.0

func (*TestProtoStruct) Descriptor() ([]byte, []int)

Deprecated: Use TestProtoStruct.ProtoReflect.Descriptor instead.

func (*TestProtoStruct) GetValue added in v0.4.0

func (x *TestProtoStruct) GetValue() int64

func (*TestProtoStruct) ProtoMessage added in v0.4.0

func (*TestProtoStruct) ProtoMessage()

func (*TestProtoStruct) ProtoReflect added in v0.4.0

func (x *TestProtoStruct) ProtoReflect() protoreflect.Message

func (*TestProtoStruct) Reset added in v0.4.0

func (x *TestProtoStruct) Reset()

func (*TestProtoStruct) String added in v0.4.0

func (x *TestProtoStruct) String() string

type TestTags added in v0.4.0

type TestTags struct {
	Data *TestTagsData `protobuf:"bytes,1,opt,name=Data,json=data,proto3" json:"Data,omitempty"`
	// contains filtered or unexported fields
}

func (*TestTags) Descriptor deprecated added in v0.4.0

func (*TestTags) Descriptor() ([]byte, []int)

Deprecated: Use TestTags.ProtoReflect.Descriptor instead.

func (*TestTags) GetData added in v0.4.0

func (x *TestTags) GetData() *TestTagsData

func (*TestTags) ProtoMessage added in v0.4.0

func (*TestTags) ProtoMessage()

func (*TestTags) ProtoReflect added in v0.4.0

func (x *TestTags) ProtoReflect() protoreflect.Message

func (*TestTags) Reset added in v0.4.0

func (x *TestTags) Reset()

func (*TestTags) String added in v0.4.0

func (x *TestTags) String() string

type TestTagsData added in v0.4.0

type TestTagsData struct {
	UploadFile       string  `protobuf:"bytes,1,opt,name=UploadFile,json=uploadFile,proto3" json:"UploadFile,omitempty"`
	UploadUrl        string  `protobuf:"bytes,2,opt,name=UploadUrl,json=uploadUrl,proto3" json:"UploadUrl,omitempty"`
	MetadataOnly     string  `protobuf:"bytes,3,opt,name=MetadataOnly,json=metadataOnly,proto3" json:"MetadataOnly,omitempty"`
	ContentTypeId    int64   `protobuf:"varint,4,opt,name=ContentTypeId,json=contentTypeId,proto3" json:"ContentTypeId,omitempty"`
	CreativeApiId    int64   `protobuf:"varint,5,opt,name=CreativeApiId,json=creativeApiId,proto3" json:"CreativeApiId,omitempty"`
	Duration         int32   `protobuf:"zigzag32,6,opt,name=Duration,json=duration,proto3" json:"Duration,omitempty"`
	PhysicalDuration float32 `protobuf:"fixed32,7,opt,name=PhysicalDuration,json=physicalDuration,proto3" json:"PhysicalDuration,omitempty"`
	Bitrate          int32   `protobuf:"zigzag32,8,opt,name=Bitrate,json=bitrate,proto3" json:"Bitrate,omitempty"`
	Height           int32   `protobuf:"zigzag32,9,opt,name=Height,json=height,proto3" json:"Height,omitempty"`
	Width            int32   `protobuf:"zigzag32,10,opt,name=Width,json=width,proto3" json:"Width,omitempty"`
	Fps              float32 `protobuf:"fixed32,11,opt,name=Fps,json=fps,proto3" json:"Fps,omitempty"`
	Id3Tag           string  `protobuf:"bytes,12,opt,name=Id3Tag,json=id3Tag,proto3" json:"Id3Tag,omitempty"`
	// contains filtered or unexported fields
}

func (*TestTagsData) Descriptor deprecated added in v0.4.0

func (*TestTagsData) Descriptor() ([]byte, []int)

Deprecated: Use TestTagsData.ProtoReflect.Descriptor instead.

func (*TestTagsData) GetBitrate added in v0.4.0

func (x *TestTagsData) GetBitrate() int32

func (*TestTagsData) GetContentTypeId added in v0.4.0

func (x *TestTagsData) GetContentTypeId() int64

func (*TestTagsData) GetCreativeApiId added in v0.4.0

func (x *TestTagsData) GetCreativeApiId() int64

func (*TestTagsData) GetDuration added in v0.4.0

func (x *TestTagsData) GetDuration() int32

func (*TestTagsData) GetFps added in v0.4.0

func (x *TestTagsData) GetFps() float32

func (*TestTagsData) GetHeight added in v0.4.0

func (x *TestTagsData) GetHeight() int32

func (*TestTagsData) GetId3Tag added in v0.4.0

func (x *TestTagsData) GetId3Tag() string

func (*TestTagsData) GetMetadataOnly added in v0.4.0

func (x *TestTagsData) GetMetadataOnly() string

func (*TestTagsData) GetPhysicalDuration added in v0.4.0

func (x *TestTagsData) GetPhysicalDuration() float32

func (*TestTagsData) GetUploadFile added in v0.4.0

func (x *TestTagsData) GetUploadFile() string

func (*TestTagsData) GetUploadUrl added in v0.4.0

func (x *TestTagsData) GetUploadUrl() string

func (*TestTagsData) GetWidth added in v0.4.0

func (x *TestTagsData) GetWidth() int32

func (*TestTagsData) ProtoMessage added in v0.4.0

func (*TestTagsData) ProtoMessage()

func (*TestTagsData) ProtoReflect added in v0.4.0

func (x *TestTagsData) ProtoReflect() protoreflect.Message

func (*TestTagsData) Reset added in v0.4.0

func (x *TestTagsData) Reset()

func (*TestTagsData) String added in v0.4.0

func (x *TestTagsData) String() string

type ThriftServer

type ThriftServer struct {
	*Server
	// contains filtered or unexported fields
}

func NewThriftServer

func NewThriftServer(initializer Initializable, configFilePath string) *ThriftServer

func (*ThriftServer) ServerField

func (s *ThriftServer) ServerField() *Server

func (*ThriftServer) Service

func (s *ThriftServer) Service(serviceName string) interface{}

ThriftService returns a Thrift client instance, example: client := turbo.ThriftService().(proto.YourServiceClient)

func (*ThriftServer) Start

func (s *ThriftServer) Start(clientCreator thriftClientCreator, sw switcher, registerTProcessor processorRegister)

Start starts both HTTP server and Thrift service

func (*ThriftServer) StartHTTPServer

func (s *ThriftServer) StartHTTPServer(clientCreator thriftClientCreator, sw switcher)

StartHTTPServer starts a HTTP server which sends requests via Thrift

func (*ThriftServer) StartThriftService

func (s *ThriftServer) StartThriftService(registerTProcessor processorRegister)

StartThriftService starts a Thrift service

func (*ThriftServer) Stop

func (s *ThriftServer) Stop()

Directories

Path Synopsis
* Copyright © 2017 Xiao Zhang <zzxx513@gmail.com>.
* Copyright © 2017 Xiao Zhang <zzxx513@gmail.com>.
testservice/gen
Code generated by turbo.
Code generated by turbo.
testservice/gen/proto
Package proto is a generated protocol buffer package.
Package proto is a generated protocol buffer package.
* Copyright © 2017 Xiao Zhang <zzxx513@gmail.com>.
* Copyright © 2017 Xiao Zhang <zzxx513@gmail.com>.
cmd
* Copyright © 2017 Xiao Zhang <zzxx513@gmail.com>.
* Copyright © 2017 Xiao Zhang <zzxx513@gmail.com>.

Jump to

Keyboard shortcuts

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