micro

package module
v0.0.0-...-315a808 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2024 License: MIT Imports: 6 Imported by: 0

README

微服务框架,缝合来源

- go-micro

- pitaya

文件夹说明

  • breaker 熔断器
  • broker 异步推送(默认kafka)
  • breaker grpc客户端
  • codec 序列化工具
  • errors 通用错误
  • interfaces 通用接口
  • log 日志
  • registry 注册服务
  • resolver
  • selector 选择器
  • tracing 链路追踪
  • transport grpc传输层
  • utils 通用工具

IDEA 设置

  • Ctrl+Shift+A 搜索Registry并点击
取消勾选下列值
go.run.processes.with.pty
terminal.use.conpty.on.windows

Documentation

Index

Constants

View Source
const (
	HeaderNode  = "X-Node-Id" // 限定 node
	ContentType = "Content-Type"
	Accept      = "Accept"
)

Variables

View Source
var (
	// ErrIPNotFound no IP address found, and explicit IP not provided.
	ErrIPNotFound = errors.New("no IP address found, and explicit IP not provided")

	ErrServiceNotFound = errors.New("service not found")
	ErrWatcherStopped  = errors.New("watcher stopped")

	ErrSelectServiceNotFound = errors.New("not found")
	ErrNoneServiceAvailable  = errors.New("none available")
)
View Source
var (
	DefaultCodecs = map[string]string{

		"text/html":              "application/grpc+bytes",
		"text/plain":             "application/grpc+bytes",
		"application/grpc+json":  "application/grpc+json",
		"application/grpc+proto": "application/grpc+proto",
		"application/grpc+bytes": "application/grpc+bytes",

		"application/json":         "application/grpc+json",
		"application/grpc":         "application/grpc+proto",
		"application/protobuf":     "application/grpc+proto",
		"application/octet-stream": "application/grpc+bytes",
	}
)

Functions

func MatchCodec

func MatchCodec(protocol, codec string) bool

Types

type Component

type Component interface {
	Init()
	AfterInit()
	BeforeShutdown()
	Shutdown()

	Name() string
	Internal() bool
}

type ComponentBase

type ComponentBase struct {
}

func (*ComponentBase) AfterInit

func (*ComponentBase) AfterInit()

func (*ComponentBase) BeforeShutdown

func (*ComponentBase) BeforeShutdown()

func (*ComponentBase) Init

func (*ComponentBase) Init()

func (*ComponentBase) Internal

func (*ComponentBase) Internal() bool

func (*ComponentBase) Shutdown

func (*ComponentBase) Shutdown()

type Endpoint

type Endpoint struct {
	Name     string            `json:"name"`
	Internal bool              `json:"internal,omitempty"` // 是否内部方法(不可通过外部网关转发)
	Metadata map[string]string `json:"metadata"`           // 元数据
}

type Module

type Module interface {
	Init() error
	AfterInit()
	BeforeShutdown()
	Shutdown() error
}

Module is the interface that represent a module.

type Node

type Node struct {
	Id       string            `json:"id"`
	Version  string            `json:"version"` // 节点版本号
	Address  string            `json:"address"`
	Metadata map[string]string `json:"metadata"`
}

type Protocols

type Protocols struct {
	ContentType string // 原始
	Accept      string
	Reqeust     string
	Response    string
}

type Registry

type Registry interface {
	Register(*Service) error
	Deregister(*Service) error
	GetService(service string) ([]*Service, error)
	ListServices() ([]*Service, error)
	Watch(service string) (Watcher, error)
	String() string
}

type Request

type Request interface {
	// The service to call
	Service() string
	// The action to take
	Method() string
	// The endpoint to invoke
	Endpoint() string
	// The content type
	Protocols() *Protocols
	// The unencoded request body
	Body() interface{}
	// service version fileter
	Version() *Version
}

Request is the interface for a synchronous request used by Call or Stream.

type Response

type Response interface {
	// Read the response
	Codec() codec.Reader
	// read the header
	Header() map[string]string
	// Read the undecoded response
	Read() ([]byte, error)
}

Response is the response received from a service.

type Result

type Result struct {
	Service *Service
	Action  string
}

type Service

type Service struct {
	Name      string            `json:"name"`
	Version   string            `json:"version"` // 当前版本号
	Metadata  map[string]string `json:"metadata"`
	Nodes     []*Node           `json:"nodes"`
	Endpoints []*Endpoint       `json:"endpoints"`
}

type Stream

type Stream interface {
	CloseSend() error
	// Context for the stream
	Context() context.Context
	// The request made
	Request() Request
	// The response read
	Response() Response
	// Send will encode and send a request
	Send(interface{}) error
	// Recv will decode and read a response
	Recv(interface{}) error
	// Error returns the stream error
	Error() error
	// Close closes the stream
	Close() error
}

Stream is the inteface for a bidirectional synchronous stream.

type Target

type Target struct {
	Method   string   // http method
	Service  string   // service
	Version  *Version // service version
	Endpoint string   // service endpoint
}

type Version

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

func NewVersion

func NewVersion(v string) (*Version, error)

func (*Version) Main

func (v *Version) Main() string

func (*Version) Major

func (v *Version) Major() int

Major 主版本

func (*Version) Minor

func (v *Version) Minor() int

Minor 次版本

func (*Version) Version

func (v *Version) Version() string

type Watcher

type Watcher interface {
	// Next is a blocking call
	Next() (*Result, error)
	Stop()
}

Directories

Path Synopsis
Package client is an interface for an RPC client
Package client is an interface for an RPC client
buf
Package codec is an interface for encoding messages
Package codec is an interface for encoding messages
grpc
Package grpc provides a grpc codec
Package grpc provides a grpc codec
Package errors provides a way to return detailed information for an RPC request error.
Package errors provides a way to return detailed information for an RPC request error.
cache
Package cache provides a registry cache
Package cache provides a registry cache
Package transport is an interface for synchronous connection based communication
Package transport is an interface for synchronous connection based communication
aes
flock
Package flock implements a thread-safe interface for file locking.
Package flock implements a thread-safe interface for file locking.

Jump to

Keyboard shortcuts

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