metadata

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: May 29, 2025 License: MIT Imports: 23 Imported by: 0

Documentation

Overview

this file is copied from https://github.com/go-kratos/kratos/blob/main/api/metadata/server.go

Index

Constants

This section is empty.

Variables

View Source
var File_metadata_metadata_proto protoreflect.FileDescriptor
View Source
var Metadata_ServiceDesc = grpc.ServiceDesc{
	ServiceName: "kratos.api.Metadata",
	HandlerType: (*MetadataServer)(nil),
	Methods: []grpc.MethodDesc{
		{
			MethodName: "ListServices",
			Handler:    _Metadata_ListServices_Handler,
		},
		{
			MethodName: "GetServiceDesc",
			Handler:    _Metadata_GetServiceDesc_Handler,
		},
	},
	Streams:  []grpc.StreamDesc{},
	Metadata: "metadata/metadata.proto",
}

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

Functions

func AppendToClientContext

func AppendToClientContext(ctx context.Context, kv ...string) context.Context

AppendToClientContext returns a new context with the provided kv merged with any existing metadata in the context.

func MergeToClientContext

func MergeToClientContext(ctx context.Context, cmd Metadata) context.Context

MergeToClientContext merge new metadata into ctx.

func NewClientContext

func NewClientContext(ctx context.Context, md Metadata) context.Context

NewClientContext creates a new context with client md attached.

func NewServerContext

func NewServerContext(ctx context.Context, md Metadata) context.Context

NewServerContext creates a new context with client md attached.

func RegisterMetadataHTTPServer

func RegisterMetadataHTTPServer(s *http.Server, srv MetadataHTTPServer)

func RegisterMetadataServer

func RegisterMetadataServer(s grpc.ServiceRegistrar, srv MetadataServer)

Types

type GetServiceDescReply

type GetServiceDescReply struct {
	FileDescSet *descriptorpb.FileDescriptorSet `protobuf:"bytes,1,opt,name=file_desc_set,json=fileDescSet,proto3" json:"file_desc_set,omitempty"`
	// contains filtered or unexported fields
}

func (*GetServiceDescReply) Descriptor deprecated

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

Deprecated: Use GetServiceDescReply.ProtoReflect.Descriptor instead.

func (*GetServiceDescReply) GetFileDescSet

func (x *GetServiceDescReply) GetFileDescSet() *descriptorpb.FileDescriptorSet

func (*GetServiceDescReply) ProtoMessage

func (*GetServiceDescReply) ProtoMessage()

func (*GetServiceDescReply) ProtoReflect

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

func (*GetServiceDescReply) Reset

func (x *GetServiceDescReply) Reset()

func (*GetServiceDescReply) String

func (x *GetServiceDescReply) String() string

type GetServiceDescRequest

type GetServiceDescRequest struct {
	Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
	// contains filtered or unexported fields
}

func (*GetServiceDescRequest) Descriptor deprecated

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

Deprecated: Use GetServiceDescRequest.ProtoReflect.Descriptor instead.

func (*GetServiceDescRequest) GetName

func (x *GetServiceDescRequest) GetName() string

func (*GetServiceDescRequest) ProtoMessage

func (*GetServiceDescRequest) ProtoMessage()

func (*GetServiceDescRequest) ProtoReflect

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

func (*GetServiceDescRequest) Reset

func (x *GetServiceDescRequest) Reset()

func (*GetServiceDescRequest) String

func (x *GetServiceDescRequest) String() string

type ListServicesReply

type ListServicesReply struct {
	Services []string `protobuf:"bytes,1,rep,name=services,proto3" json:"services,omitempty"`
	Methods  []string `protobuf:"bytes,2,rep,name=methods,proto3" json:"methods,omitempty"`
	// contains filtered or unexported fields
}

func (*ListServicesReply) Descriptor deprecated

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

Deprecated: Use ListServicesReply.ProtoReflect.Descriptor instead.

func (*ListServicesReply) GetMethods

func (x *ListServicesReply) GetMethods() []string

func (*ListServicesReply) GetServices

func (x *ListServicesReply) GetServices() []string

func (*ListServicesReply) ProtoMessage

func (*ListServicesReply) ProtoMessage()

func (*ListServicesReply) ProtoReflect

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

func (*ListServicesReply) Reset

func (x *ListServicesReply) Reset()

func (*ListServicesReply) String

func (x *ListServicesReply) String() string

type ListServicesRequest

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

func (*ListServicesRequest) Descriptor deprecated

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

Deprecated: Use ListServicesRequest.ProtoReflect.Descriptor instead.

func (*ListServicesRequest) ProtoMessage

func (*ListServicesRequest) ProtoMessage()

func (*ListServicesRequest) ProtoReflect

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

func (*ListServicesRequest) Reset

func (x *ListServicesRequest) Reset()

func (*ListServicesRequest) String

func (x *ListServicesRequest) String() string

type Metadata

type Metadata map[string][]string

Metadata is our way of representing request headers internally. They're used at the RPC level and translate back and forth from Transport headers.

func FromClientContext

func FromClientContext(ctx context.Context) (Metadata, bool)

FromClientContext returns the client metadata in ctx if it exists.

func FromServerContext

func FromServerContext(ctx context.Context) (Metadata, bool)

FromServerContext returns the server metadata in ctx if it exists.

func New

func New(mds ...map[string][]string) Metadata

New creates an MD from a given key-values map.

func (Metadata) Add

func (m Metadata) Add(key, value string)

Add adds the key, value pair to the header.

func (Metadata) Clone

func (m Metadata) Clone() Metadata

Clone returns a deep copy of Metadata

func (Metadata) Get

func (m Metadata) Get(key string) string

Get returns the value associated with the passed key.

func (Metadata) Range

func (m Metadata) Range(f func(k string, v []string) bool)

Range iterate over element in metadata.

func (Metadata) Set

func (m Metadata) Set(key string, value string)

Set stores the key-value pair.

func (Metadata) Values

func (m Metadata) Values(key string) []string

Values returns a slice of values associated with the passed key.

type MetadataClient

type MetadataClient interface {
	// ListServices list the full name of all services.
	ListServices(ctx context.Context, in *ListServicesRequest, opts ...grpc.CallOption) (*ListServicesReply, error)
	// GetServiceDesc get the full fileDescriptorSet of service.
	GetServiceDesc(ctx context.Context, in *GetServiceDescRequest, opts ...grpc.CallOption) (*GetServiceDescReply, error)
}

MetadataClient is the client API for Metadata 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 NewMetadataClient

func NewMetadataClient(cc grpc.ClientConnInterface) MetadataClient

type MetadataHTTPClient

type MetadataHTTPClient interface {
	GetServiceDesc(ctx context.Context, req *GetServiceDescRequest, opts ...http.CallOption) (rsp *GetServiceDescReply, err error)
	ListServices(ctx context.Context, req *ListServicesRequest, opts ...http.CallOption) (rsp *ListServicesReply, err error)
}

func NewMetadataHTTPClient

func NewMetadataHTTPClient(client *http.Client) MetadataHTTPClient

type MetadataHTTPClientImpl

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

func (*MetadataHTTPClientImpl) GetServiceDesc

func (*MetadataHTTPClientImpl) ListServices

type MetadataHTTPServer

type MetadataHTTPServer interface {
	GetServiceDesc(context.Context, *GetServiceDescRequest) (*GetServiceDescReply, error)
	ListServices(context.Context, *ListServicesRequest) (*ListServicesReply, error)
}

type MetadataServer

type MetadataServer interface {
	// ListServices list the full name of all services.
	ListServices(context.Context, *ListServicesRequest) (*ListServicesReply, error)
	// GetServiceDesc get the full fileDescriptorSet of service.
	GetServiceDesc(context.Context, *GetServiceDescRequest) (*GetServiceDescReply, error)
	// contains filtered or unexported methods
}

MetadataServer is the server API for Metadata service. All implementations must embed UnimplementedMetadataServer for forward compatibility

type Server

type Server struct {
	UnimplementedMetadataServer
	// contains filtered or unexported fields
}

Server is api meta server

func NewServer

func NewServer(srv *grpc.Server) *Server

NewServer create server instance

func (*Server) GetServiceDesc

func (s *Server) GetServiceDesc(_ context.Context, in *GetServiceDescRequest) (*GetServiceDescReply, error)

GetServiceDesc return service meta by name

func (*Server) ListServices

func (s *Server) ListServices(_ context.Context, _ *ListServicesRequest) (*ListServicesReply, error)

ListServices return all services

type UnimplementedMetadataServer

type UnimplementedMetadataServer struct {
}

UnimplementedMetadataServer must be embedded to have forward compatible implementations.

func (UnimplementedMetadataServer) GetServiceDesc

func (UnimplementedMetadataServer) ListServices

type UnsafeMetadataServer

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

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

Jump to

Keyboard shortcuts

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