common

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2024 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client interface {
	// Token 返回当前客户端使用的 Token
	Token() string
	// WithToken 返回使用指定 Token 的客户端
	WithToken(token string) Client
	// Login 登陆获取用户身份返回登陆后的客户端
	Login(ctx context.Context, opts LoginOptions) (Client, error)
	// CreateSelfSubjectReview 检查自身身份
	CreateSelfSubjectReview(ctx context.Context, review *authnv1.SelfSubjectReview) (*authnv1.SelfSubjectReview, error)
	// CreateStream 创建流
	CreateStream(ctx context.Context, stream *streamv1.Stream) (*streamv1.Stream, error)
	// GetStream 获取流
	GetStream(ctx context.Context, name string) (*streamv1.Stream, error)
	// ListStreams 列出流
	ListStreams(ctx context.Context) (*streamv1.StreamList, error)
	// DeleteStream 删除流
	DeleteStream(ctx context.Context, name string) error
	// ConnectStream 连接到流
	ConnectStream(ctx context.Context, name string, opts ConnectStreamOptions) (streams.Connection, error)
}

Client 客户端

func NewClient

func NewClient(opts ClientOptions) (Client, error)

NewClient 创建客户端

func NewGRPCClient

func NewGRPCClient(opts GRPCClientOptions) (Client, error)

NewGRPCClient 创建基于 gRPC 的客户端

func NewHTTPClient

func NewHTTPClient(opts HTTPClientOptions) (Client, error)

NewHTTPClient 创建基于 HTTP 的客户端

func NewWithPersistentTokenClient

func NewWithPersistentTokenClient(client Client, tokenFile string) Client

NewWithPersistentTokenClient 创建带持久化 Token 的客户端

type ClientOptions

type ClientOptions struct {
	// 服务端 URL
	Server string
	// 用于认证的 Token
	Token string
	// 对传输数据进行压缩
	Compress bool
}

ClientOptions 客户端选项

type ConnectStreamOptions

type ConnectStreamOptions struct {
	ConnectionName string
}

ConnectStreamOptions 连接到流选项

type GRPCClientOptions

type GRPCClientOptions struct {
	// 服务端地址
	ServerAddress string
	// 用于认证的 Token
	Token string
	// 对传输数据进行压缩
	Compress bool
}

GRPCClientOptions gRPC 客户端选项

func (*GRPCClientOptions) Complete

func (opts *GRPCClientOptions) Complete()

Complete 将选项补充完整

type HTTPClientOptions

type HTTPClientOptions struct {
	// 服务端 URL
	ServerURL string
	// 用于认证的 Token
	Token string
}

HTTPClientOptions HTTP 客户端选项

func (*HTTPClientOptions) Complete

func (opts *HTTPClientOptions) Complete()

Complete 将选项补充完整

func (*HTTPClientOptions) Validate

func (opts *HTTPClientOptions) Validate() error

Validate 校验选项

type LoginOptions

type LoginOptions struct {
	// 是否更换用户
	RenewUser bool
}

LoginOptions 登陆选项

type WithPersistentTokenClient

type WithPersistentTokenClient struct {
	Client
	// contains filtered or unexported fields
}

WithPersistentTokenClient 带持久化 Token 的客户端

func (*WithPersistentTokenClient) Login

Login 登陆获取用户身份返回登陆后的客户端

Jump to

Keyboard shortcuts

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