giraffe

package module
v1.0.5 Latest Latest
Warning

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

Go to latest
Published: May 25, 2023 License: GPL-3.0 Imports: 3 Imported by: 208

README

giraffe-micro

GiraffeMicro 是一个微服务框架,提供了 RESTFul 和 gRPC 实现。并提供了名字服务接口

Build Status Coverage Status GoDoc Go Report Card LICENSE

Quick Start

Documentation

Index

Constants

View Source
const (

	//SupportPackageIsVersion4 当前框架版本
	SupportPackageIsVersion4 = true
)

Variables

This section is empty.

Functions

This section is empty.

Types

type CallOption added in v0.5.0

type CallOption func(o *CallOptions)

CallOption 请求配置函数

type CallOptions added in v0.5.0

type CallOptions struct {
	Metadata metadata.MD
}

CallOptions 请求配置

type Client

type Client interface {
	Invoke(ctx context.Context, md *MethodDesc, in interface{}, out interface{}, opts ...CallOption) error
	NewStream(ctx context.Context, sd *StreamDesc, opts ...CallOption) (ClientStream, error)
}

Client 客户端接口

type ClientStream

type ClientStream interface {
	SendMsg(m interface{}) error
	RecvMsg(m interface{}) error
	CloseSend() error
}

ClientStream 流式客户端接口

type Contract

type Contract interface {
	GetName() string
	GetVersion() string
}

Contract 契约定义接口

type HttpRule

type HttpRule interface {
	GetGet() string
	GetPut() string
	GetPost() string
	GetDelete() string
	GetPatch() string
	GetBody() string
	GetResponseBody() string
}

HttpRule HTTP规则定义接口

type MethodDesc added in v0.4.0

type MethodDesc struct {
	Contract     Contract
	ServiceName  string
	MethodName   string
	RequestType  interface{}
	ResponseType interface{}
	HttpRule     HttpRule
}

MethodDesc 单次调用方法定义

type NameService

type NameService interface {
	GetAddress(ctx context.Context, contract Contract) (string, error)
	GetAllAddresses(ctx context.Context, contract Contract) ([]string, error)
}

NameService 名字服务接口

type Server

type Server interface {
	RegisterUnaryEndpoint(md *MethodDesc, handle UnaryEndpoint)
	RegisterStreamEndpoint(sd *StreamDesc, handle StreamEndpoint)
}

Server 服务端接口

type ServiceStream

type ServiceStream interface {
	// TODO add support SetHeader() SendHeader() SetTrailer()
	SendMsg(m interface{}) error
	RecvMsg(m interface{}) error
}

ServiceStream 流式服务接口

type StatusCode added in v0.4.0

type StatusCode interface {
	StatusCode() codes.Code
}

StatusCode 统一状态码接口

type StreamDesc added in v0.4.0

type StreamDesc struct {
	Contract      Contract
	ServiceName   string
	StreamName    string
	ClientStreams bool
	ServerStreams bool
}

StreamDesc 流式调用方法定义

type StreamEndpoint

type StreamEndpoint func(ctx context.Context, stream ServiceStream) error

StreamEndpoint 流式调用函数

type UnaryEndpoint

type UnaryEndpoint func(ctx context.Context, req interface{}) (interface{}, error)

UnaryEndpoint 单次调用函数

Directories

Path Synopsis
pkg
plugins
test

Jump to

Keyboard shortcuts

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