dkit

package
v0.0.0-...-14d6b26 Latest Latest
Warning

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

Go to latest
Published: May 7, 2026 License: Apache-2.0 Imports: 23 Imported by: 0

README

发送grpc请求

可以通过curl完成:

no_proxy='*' curl --http2-prior-knowledge -XPOST -d'{}' http://host_ip_or_domain:80 -v -H 'Content-Type:application/grpc'

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddDeleteMergedBranchesCmd

func AddDeleteMergedBranchesCmd(rootCmd *cobra.Command)

func AddGrpcCmd

func AddGrpcCmd(rootCmd *cobra.Command)

func DeleteMergedBranches

func DeleteMergedBranches(req *DeleteMergedBranchesReq) error

func GrpcMain

func GrpcMain(req *GrpcMainReq) error

func NewGrpcClient

func NewGrpcClient(conf *GrpcClientConfig) (*grpc.ClientConn, error)

Types

type Codec

type Codec interface {
	// CreateReqObj builds the Invoke request value (proto.Message or []byte) from body.
	CreateReqObj(body []byte) (any, error)
	// CreateReplyTarget returns the reply target passed to Invoke (e.g. *dynamicpb.Message or *[]byte).
	CreateReplyTarget() any
	// GrpcCallOption returns an additional CallOption for the call, or nil to use the default proto codec.
	GrpcCallOption() grpc.CallOption
	// GetResponseOutput converts the Invoke reply into bytes to write to stdout; may return nil for empty responses.
	GetResponseOutput(resp any) ([]byte, error)
}

Codec abstracts request construction, response parsing, and gRPC call options for sendRequest.

type DeleteMergedBranchesReq

type DeleteMergedBranchesReq struct {
	DryRun bool
}

type GrpcClientConfig

type GrpcClientConfig struct {
	Host                  string
	TLS                   bool
	InitialConnWindowSize int32
	InitialWindowSize     int32
	Headers               []string
}

type GrpcMainReq

type GrpcMainReq struct {
	Host                  string
	Body                  string
	Method                string
	SubType               string
	Query                 string
	Svr                   string
	TLS                   bool
	InitialConnWindowSize int32    // 0: omit WithInitialConnWindowSize
	InitialWindowSize     int32    // 0: omit WithInitialWindowSize
	Count                 int      // number of times to send the request; default 1
	Headers               []string // "key: value" pairs sent as gRPC metadata
}

func (*GrpcMainReq) Validate

func (r *GrpcMainReq) Validate() error

type RawCodec

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

RawCodec is a gRPC codec that passes bytes through without marshaling.

func NewRawCodec

func NewRawCodec(name string) *RawCodec

func (*RawCodec) Marshal

func (c *RawCodec) Marshal(v any) ([]byte, error)

func (*RawCodec) Name

func (c *RawCodec) Name() string

func (*RawCodec) Unmarshal

func (c *RawCodec) Unmarshal(data []byte, v any) error

type ReflectionClient

type ReflectionClient interface {
	ListServices(ctx context.Context) ([]string, error)
	ListMethods(ctx context.Context, service string) ([]string, error)
	GetFileDescriptorsBySymbol(ctx context.Context, symbol string) ([]*descriptorpb.FileDescriptorProto, error)
	Close() error
}

func NewReflectionClient

func NewReflectionClient(ctx context.Context, conf *GrpcClientConfig) (ReflectionClient, error)

NewReflectionClient tries v1 and v1alpha with independent connections, returns the first that succeeds, or both errors if both fail.

Directories

Path Synopsis
cmd
dkit command

Jump to

Keyboard shortcuts

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