service

package
v0.0.0-...-f4657ca Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2023 License: GPL-3.0 Imports: 12 Imported by: 1

Documentation

Index

Constants

View Source
const (
	SERVICE_CLIENT_ID     = "client_id"
	SERVICE_CLIENT_SECRET = "client_secret"
)

定义context中的grpc认证头

View Source
const (
	RPC_QueryService_FullMethodName             = "/codehorse.mcenter.service.RPC/QueryService"
	RPC_DescribeService_FullMethodName          = "/codehorse.mcenter.service.RPC/DescribeService"
	RPC_QueryServiceIdByClientId_FullMethodName = "/codehorse.mcenter.service.RPC/QueryServiceIdByClientId"
)
View Source
const (
	AppName = "service"
)

模块名称

Variables

View Source
var (
	DESCRIBE_BY_name = map[int32]string{
		0: "SERVICE_ID",
		1: "SERVICE_CREDENTIAL_ID",
	}
	DESCRIBE_BY_value = map[string]int32{
		"SERVICE_ID":            0,
		"SERVICE_CREDENTIAL_ID": 1,
	}
)

Enum value maps for DESCRIBE_BY.

View Source
var File_apps_service_pb_rpc_proto protoreflect.FileDescriptor
View Source
var File_apps_service_pb_service_proto protoreflect.FileDescriptor
View Source
var RPC_ServiceDesc = grpc.ServiceDesc{
	ServiceName: "codehorse.mcenter.service.RPC",
	HandlerType: (*RPCServer)(nil),
	Methods: []grpc.MethodDesc{
		{
			MethodName: "QueryService",
			Handler:    _RPC_QueryService_Handler,
		},
		{
			MethodName: "DescribeService",
			Handler:    _RPC_DescribeService_Handler,
		},
		{
			MethodName: "QueryServiceIdByClientId",
			Handler:    _RPC_QueryServiceIdByClientId_Handler,
		},
	},
	Streams:  []grpc.StreamDesc{},
	Metadata: "apps/service/pb/rpc.proto",
}

RPC_ServiceDesc is the grpc.ServiceDesc for RPC service. It's only intended for direct use with grpc.RegisterService, and not to be introspected or modified (even as a copy)

Functions

func RegisterRPCServer

func RegisterRPCServer(s grpc.ServiceRegistrar, srv RPCServer)

Types

type CreateServiceRequest

type CreateServiceRequest struct {

	// @gotags: bson:"domain" json:"domain"
	Domain string `protobuf:"bytes,1,opt,name=domain,proto3" json:"domain" bson:"domain"`
	// @gotags: bson:"namespace" json:"namespace"
	Namespace string `protobuf:"bytes,2,opt,name=namespace,proto3" json:"namespace" bson:"namespace"`
	// @gotags: bson:"name" json:"name"
	Name string `protobuf:"bytes,3,opt,name=name,proto3" json:"name" bson:"name"`
	// contains filtered or unexported fields
}

CreateServiceRequest结构体

func NewCreateServiceRequest

func NewCreateServiceRequest() *CreateServiceRequest

CreateServiceRequest构造函数

func (*CreateServiceRequest) Descriptor deprecated

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

Deprecated: Use CreateServiceRequest.ProtoReflect.Descriptor instead.

func (*CreateServiceRequest) GetDomain

func (x *CreateServiceRequest) GetDomain() string

func (*CreateServiceRequest) GetName

func (x *CreateServiceRequest) GetName() string

func (*CreateServiceRequest) GetNamespace

func (x *CreateServiceRequest) GetNamespace() string

func (*CreateServiceRequest) ProtoMessage

func (*CreateServiceRequest) ProtoMessage()

func (*CreateServiceRequest) ProtoReflect

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

func (*CreateServiceRequest) Reset

func (x *CreateServiceRequest) Reset()

func (*CreateServiceRequest) String

func (x *CreateServiceRequest) String() string

type Credential

type Credential struct {

	// @gotags: bson:"create_at" json:"create_at"
	CreateAt int64 `protobuf:"varint,1,opt,name=create_at,json=createAt,proto3" json:"create_at" bson:"create_at"`
	// @gotags: bson:"client_id" json:"client_id"
	ClientId string `protobuf:"bytes,2,opt,name=client_id,json=clientId,proto3" json:"client_id" bson:"client_id"`
	// @gotags: bson:"client_secret" json:"client_secret"
	ClientSecret string `protobuf:"bytes,3,opt,name=client_secret,json=clientSecret,proto3" json:"client_secret" bson:"client_secret"`
	// contains filtered or unexported fields
}

Credential结构体

func NewCredential

func NewCredential() *Credential

Credential构造函数

func (*Credential) Descriptor deprecated

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

Deprecated: Use Credential.ProtoReflect.Descriptor instead.

func (*Credential) GetClientId

func (x *Credential) GetClientId() string

func (*Credential) GetClientSecret

func (x *Credential) GetClientSecret() string

func (*Credential) GetCreateAt

func (x *Credential) GetCreateAt() int64

func (*Credential) ProtoMessage

func (*Credential) ProtoMessage()

func (*Credential) ProtoReflect

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

func (*Credential) Reset

func (x *Credential) Reset()

func (*Credential) String

func (x *Credential) String() string

type DESCRIBE_BY

type DESCRIBE_BY int32

查询Service的枚举类型

const (
	DESCRIBE_BY_SERVICE_ID            DESCRIBE_BY = 0
	DESCRIBE_BY_SERVICE_CREDENTIAL_ID DESCRIBE_BY = 1
)

func (DESCRIBE_BY) Descriptor

func (DESCRIBE_BY) Enum

func (x DESCRIBE_BY) Enum() *DESCRIBE_BY

func (DESCRIBE_BY) EnumDescriptor deprecated

func (DESCRIBE_BY) EnumDescriptor() ([]byte, []int)

Deprecated: Use DESCRIBE_BY.Descriptor instead.

func (DESCRIBE_BY) Number

func (x DESCRIBE_BY) Number() protoreflect.EnumNumber

func (DESCRIBE_BY) String

func (x DESCRIBE_BY) String() string

func (DESCRIBE_BY) Type

type DescribeServiceRequest

type DescribeServiceRequest struct {

	// @gotags: bson:"describe_type" json:"describe_type"
	DescribeType DESCRIBE_BY `` /* 152-byte string literal not displayed */
	// @gotags: bson:"describe_value" json:"describe_value"
	DescribeValue string `protobuf:"bytes,2,opt,name=describe_value,json=describeValue,proto3" json:"describe_value" bson:"describe_value"`
	// contains filtered or unexported fields
}

DescribeServiceRequest结构体

func NewDescribeServiceRequest

func NewDescribeServiceRequest() *DescribeServiceRequest

DescribeServiceRequest构造函数

func (*DescribeServiceRequest) Descriptor deprecated

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

Deprecated: Use DescribeServiceRequest.ProtoReflect.Descriptor instead.

func (*DescribeServiceRequest) GetDescribeType

func (x *DescribeServiceRequest) GetDescribeType() DESCRIBE_BY

func (*DescribeServiceRequest) GetDescribeValue

func (x *DescribeServiceRequest) GetDescribeValue() string

func (*DescribeServiceRequest) ProtoMessage

func (*DescribeServiceRequest) ProtoMessage()

func (*DescribeServiceRequest) ProtoReflect

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

func (*DescribeServiceRequest) Reset

func (x *DescribeServiceRequest) Reset()

func (*DescribeServiceRequest) String

func (x *DescribeServiceRequest) String() string

type QueryServiceIdByClientIdRequest

type QueryServiceIdByClientIdRequest struct {

	// @gotags: bson:"client_id" json:"client_id"
	ClientId string `protobuf:"bytes,1,opt,name=client_id,json=clientId,proto3" json:"client_id" bson:"client_id"`
	// contains filtered or unexported fields
}

QueryServiceIdByClientIdRequest结构体

func NewQueryServiceIdByClientIdRequest

func NewQueryServiceIdByClientIdRequest(clientid string) *QueryServiceIdByClientIdRequest

QueryServiceIdByClientIdRequest构造函数

func (*QueryServiceIdByClientIdRequest) Descriptor deprecated

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

Deprecated: Use QueryServiceIdByClientIdRequest.ProtoReflect.Descriptor instead.

func (*QueryServiceIdByClientIdRequest) GetClientId

func (x *QueryServiceIdByClientIdRequest) GetClientId() string

func (*QueryServiceIdByClientIdRequest) ProtoMessage

func (*QueryServiceIdByClientIdRequest) ProtoMessage()

func (*QueryServiceIdByClientIdRequest) ProtoReflect

func (*QueryServiceIdByClientIdRequest) Reset

func (*QueryServiceIdByClientIdRequest) String

type QueryServiceRequest

type QueryServiceRequest struct {

	// @gotags: bson:",inline" json:"page"
	Page *page.PageRequest `protobuf:"bytes,1,opt,name=page,proto3" json:"page" bson:",inline"`
	// @gotags: bson:"keywords" json:"keywords"
	Keywords string `protobuf:"bytes,2,opt,name=keywords,proto3" json:"keywords" bson:"keywords"`
	// contains filtered or unexported fields
}

QueryServiceRequest结构体

func (*QueryServiceRequest) Descriptor deprecated

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

Deprecated: Use QueryServiceRequest.ProtoReflect.Descriptor instead.

func (*QueryServiceRequest) GetKeywords

func (x *QueryServiceRequest) GetKeywords() string

func (*QueryServiceRequest) GetPage

func (x *QueryServiceRequest) GetPage() *page.PageRequest

func (*QueryServiceRequest) ProtoMessage

func (*QueryServiceRequest) ProtoMessage()

func (*QueryServiceRequest) ProtoReflect

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

func (*QueryServiceRequest) Reset

func (x *QueryServiceRequest) Reset()

func (*QueryServiceRequest) String

func (x *QueryServiceRequest) String() string

type RPCClient

type RPCClient interface {
	// 创建服务
	// rpc CreateService(CreateServiceRequest) returns(Service);
	// 查询服务
	QueryService(ctx context.Context, in *QueryServiceRequest, opts ...grpc.CallOption) (*ServiceSet, error)
	// 查询服务详情
	DescribeService(ctx context.Context, in *DescribeServiceRequest, opts ...grpc.CallOption) (*Service, error)
	// 通过client id称找到service id
	QueryServiceIdByClientId(ctx context.Context, in *QueryServiceIdByClientIdRequest, opts ...grpc.CallOption) (*Service, error)
}

RPCClient is the client API for RPC service.

For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.

func NewRPCClient

func NewRPCClient(cc grpc.ClientConnInterface) RPCClient

type RPCServer

type RPCServer interface {
	// 创建服务
	// rpc CreateService(CreateServiceRequest) returns(Service);
	// 查询服务
	QueryService(context.Context, *QueryServiceRequest) (*ServiceSet, error)
	// 查询服务详情
	DescribeService(context.Context, *DescribeServiceRequest) (*Service, error)
	// 通过client id称找到service id
	QueryServiceIdByClientId(context.Context, *QueryServiceIdByClientIdRequest) (*Service, error)
	// contains filtered or unexported methods
}

RPCServer is the server API for RPC service. All implementations must embed UnimplementedRPCServer for forward compatibility

type Service

type Service struct {

	// @gotags: bson:",inline" json:"meta"
	Meta *meta.Meta `protobuf:"bytes,1,opt,name=meta,proto3" json:"meta" bson:",inline"`
	// @gotags: bson:",inline" json:"spec"
	Spec *CreateServiceRequest `protobuf:"bytes,2,opt,name=spec,proto3" json:"spec" bson:",inline"`
	// @gotags: bson:",inline" json:"credential"
	Credential *Credential `protobuf:"bytes,3,opt,name=credential,proto3" json:"credential" bson:",inline"`
	// contains filtered or unexported fields
}

Service结构体

func NewDefaultService

func NewDefaultService() *Service

Service默认构造函数

func NewService

func NewService(req *CreateServiceRequest) *Service

Service构造函数

func (*Service) Descriptor deprecated

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

Deprecated: Use Service.ProtoReflect.Descriptor instead.

func (*Service) GetCredential

func (x *Service) GetCredential() *Credential

func (*Service) GetMeta

func (x *Service) GetMeta() *meta.Meta

func (*Service) GetSpec

func (x *Service) GetSpec() *CreateServiceRequest

func (*Service) ProtoMessage

func (*Service) ProtoMessage()

func (*Service) ProtoReflect

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

func (*Service) Reset

func (x *Service) Reset()

func (*Service) String

func (x *Service) String() string

type ServiceManager

type ServiceManager interface {
	// 创建服务
	CreateService(context.Context, *CreateServiceRequest) (*Service, error)
	// 嵌套Service GRPC接口
	RPCServer
}

Service服务管理接口

type ServiceSet

type ServiceSet struct {

	// @gotags: bson:"total" json:"total"
	Total int64 `protobuf:"varint,1,opt,name=total,proto3" json:"total" bson:"total"`
	// @gotags: bson:"items" json:"items"
	Items []*Service `protobuf:"bytes,2,rep,name=items,proto3" json:"items" bson:"items"`
	// contains filtered or unexported fields
}

ServiceSet结构体

func (*ServiceSet) Descriptor deprecated

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

Deprecated: Use ServiceSet.ProtoReflect.Descriptor instead.

func (*ServiceSet) GetItems

func (x *ServiceSet) GetItems() []*Service

func (*ServiceSet) GetTotal

func (x *ServiceSet) GetTotal() int64

func (*ServiceSet) ProtoMessage

func (*ServiceSet) ProtoMessage()

func (*ServiceSet) ProtoReflect

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

func (*ServiceSet) Reset

func (x *ServiceSet) Reset()

func (*ServiceSet) String

func (x *ServiceSet) String() string

type UnimplementedRPCServer

type UnimplementedRPCServer struct {
}

UnimplementedRPCServer must be embedded to have forward compatible implementations.

func (UnimplementedRPCServer) DescribeService

func (UnimplementedRPCServer) QueryService

func (UnimplementedRPCServer) QueryServiceIdByClientId

type UnsafeRPCServer

type UnsafeRPCServer interface {
	// contains filtered or unexported methods
}

UnsafeRPCServer may be embedded to opt out of forward compatibility for this service. Use of this interface is not recommended, as added methods to RPCServer will result in compilation errors.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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