bgateway

package module
v0.0.0-...-f824949 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2022 License: MIT Imports: 14 Imported by: 2

README

BGateway SDK

介绍

BGateway是一款基于httprouterrpcx打造的高性能网关应用。可以通过可视化UI界面同时对前端Restful API和后端基于RPCX的微服务进行统一管理。

相关依赖
环境要求

go 1.19及以上

Documentation

Overview

*

  • MIT License *
  • Copyright (c) 2013-2022 北京思博森信息科技有限公司 *
  • Permission is hereby granted, free of charge, to any person obtaining a copy
  • of this software and associated documentation files (the "Software"), to deal
  • in the Software without restriction, including without limitation the rights
  • to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  • copies of the Software, and to permit persons to whom the Software is
  • furnished to do so, subject to the following conditions: *
  • The above copyright notice and this permission notice shall be included in all
  • copies or substantial portions of the Software. *
  • THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  • IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  • FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  • AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  • LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  • OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  • SOFTWARE.

*

  • MIT License *
  • Copyright (c) 2013-2022 北京思博森信息科技有限公司 *
  • Permission is hereby granted, free of charge, to any person obtaining a copy
  • of this software and associated documentation files (the "Software"), to deal
  • in the Software without restriction, including without limitation the rights
  • to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  • copies of the Software, and to permit persons to whom the Software is
  • furnished to do so, subject to the following conditions: *
  • The above copyright notice and this permission notice shall be included in all
  • copies or substantial portions of the Software. *
  • THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  • IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  • FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  • AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  • LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  • OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  • SOFTWARE.

*

  • MIT License *
  • Copyright (c) 2013-2022 北京思博森信息科技有限公司 *
  • Permission is hereby granted, free of charge, to any person obtaining a copy
  • of this software and associated documentation files (the "Software"), to deal
  • in the Software without restriction, including without limitation the rights
  • to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  • copies of the Software, and to permit persons to whom the Software is
  • furnished to do so, subject to the following conditions: *
  • The above copyright notice and this permission notice shall be included in all
  • copies or substantial portions of the Software. *
  • THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  • IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  • FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  • AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  • LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  • OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  • SOFTWARE.

*

  • MIT License *
  • Copyright (c) 2013-2022 北京思博森信息科技有限公司 *
  • Permission is hereby granted, free of charge, to any person obtaining a copy
  • of this software and associated documentation files (the "Software"), to deal
  • in the Software without restriction, including without limitation the rights
  • to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  • copies of the Software, and to permit persons to whom the Software is
  • furnished to do so, subject to the following conditions: *
  • The above copyright notice and this permission notice shall be included in all
  • copies or substantial portions of the Software. *
  • THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  • IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  • FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  • AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  • LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  • OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  • SOFTWARE.

*

  • MIT License *
  • Copyright (c) 2013-2022 北京思博森信息科技有限公司 *
  • Permission is hereby granted, free of charge, to any person obtaining a copy
  • of this software and associated documentation files (the "Software"), to deal
  • in the Software without restriction, including without limitation the rights
  • to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  • copies of the Software, and to permit persons to whom the Software is
  • furnished to do so, subject to the following conditions: *
  • The above copyright notice and this permission notice shall be included in all
  • copies or substantial portions of the Software. *
  • THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  • IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  • FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  • AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  • LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  • OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  • SOFTWARE.

*

  • MIT License *
  • Copyright (c) 2013-2022 北京思博森信息科技有限公司 *
  • Permission is hereby granted, free of charge, to any person obtaining a copy
  • of this software and associated documentation files (the "Software"), to deal
  • in the Software without restriction, including without limitation the rights
  • to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  • copies of the Software, and to permit persons to whom the Software is
  • furnished to do so, subject to the following conditions: *
  • The above copyright notice and this permission notice shall be included in all
  • copies or substantial portions of the Software. *
  • THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  • IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  • FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  • AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  • LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  • OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  • SOFTWARE.

Index

Constants

View Source
const (
	CtxTraceIdKey = "bg-traceid" // 每个请求链路的唯一标识
	CtxExtraKey   = "bg-extra"   // 扩展信息
	CtxIPKey      = "bg-ip"      // 请求IP
)

预定义context常量

Variables

This section is empty.

Functions

func CustomCodec

func CustomCodec(codec codec.Codec)

自定义编解码器

func GetCtxExtra

func GetCtxExtra(ctx context.Context) string

获取附加信息

func GetCtxIP

func GetCtxIP(ctx context.Context) string

获取IP

func GetCtxTraceId

func GetCtxTraceId(ctx context.Context) string

获取traceid

func GetRpcContextValue

func GetRpcContextValue(ctx context.Context, key string) string

获取rpc调用传递的值

func NewErr

func NewErr(err error) error

创建bgateway异常

func NewServer

func NewServer(namespace, addr string, etcds []string) (*server.Server, error)

获取server实例

func ParseErr

func ParseErr(err error) string

解析bgateway异常

func RpcCall

func RpcCall(ctx context.Context, service ServiceInfo, params, reply any) error

发起远程调用

Types

type ClientCodec

type ClientCodec struct{}

bgateway默认编解码器(client)

func (*ClientCodec) Decode

func (c *ClientCodec) Decode(data []byte, i interface{}) error

解码

func (*ClientCodec) Encode

func (c *ClientCodec) Encode(i interface{}) ([]byte, error)

编码

type CtxKey

type CtxKey string

context key类型

type RpcConfig

type RpcConfig struct {
	Namespace string   `mapstructure:"namespace"` // 注册中心空间名称
	Type      string   `mapstructure:"type"`      // 注册中间件(目前仅支持etcd3)
	Hosts     []string `mapstructure:"hosts"`     // 注册中心地址
}

rpc配置的必要信息

type ServerCodec

type ServerCodec struct{}

bgateway默认编解码器(server)

func (*ServerCodec) Decode

func (c *ServerCodec) Decode(data []byte, i interface{}) error

解码

func (*ServerCodec) Encode

func (c *ServerCodec) Encode(i interface{}) ([]byte, error)

编码

type ServiceInfo

type ServiceInfo struct {
	Namespace     string   // 注册中心空间名称
	RegistryType  string   // 注册中心中间件类型: 默认etcd3(目前仅支持)
	RegistryHosts []string // 注册中心地址
	Service       string   // service名称
	Method        string   // 方法名称
}

rpc service服务端信息

Jump to

Keyboard shortcuts

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