client

package
v0.0.0-...-535fc81 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultOptions = &Options{
	connTimeout: 15 * time.Second,
	dailOpts:    []grpc.DialOption{},
}

DefaultOptions default for a Client Options

Functions

func BuildDirectTarget

func BuildDirectTarget(uri string) string

direct target

func BuildDiscoveryTarget

func BuildDiscoveryTarget(uri string) string

discovery target

func RegisterBuilder

func RegisterBuilder(discovery registry.Discovery)

Types

type Branch

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

func NewBranch

func NewBranch(uri string, action consts.BranchAction) *Branch

func (*Branch) Convert

func (branch *Branch) Convert() *proto.RegisterReq_Branch

func (*Branch) SetData

func (branch *Branch) SetData(data []byte) *Branch

SetData set branch request data

func (*Branch) SetHeader

func (branch *Branch) SetHeader(header []byte) *Branch

SetHeader set branch header

func (*Branch) SetLevel

func (branch *Branch) SetLevel(level consts.Level) *Branch

SetLevel set branch currentLevel

func (*Branch) SetProtocol

func (branch *Branch) SetProtocol(protocol Protocol) *Branch

SetProtocol set branch network protocol

func (*Branch) SetTimeout

func (branch *Branch) SetTimeout(timeout int64) *Branch

SetTimeout set timeout for request branch

type Client

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

func New

func New(uri string, options ...Option) (client *Client, err error)

func (*Client) Begin

func (client *Client) Begin(ctx context.Context) (gid string, err error)

func (*Client) Close

func (client *Client) Close(ctx context.Context) error

func (*Client) Commit

func (client *Client) Commit(ctx context.Context, gid string) error

func (*Client) Register

func (client *Client) Register(ctx context.Context, gid string, groups []*Group) error

func (*Client) Rollback

func (client *Client) Rollback(ctx context.Context, gid string) error

func (*Client) Start

func (client *Client) Start(ctx context.Context, gid string) (err error)

type Group

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

func NewSagaGroup

func NewSagaGroup(normalUri, compensation string, opts ...GroupOpt) *Group

func NewTccGroup

func NewTccGroup(tryUri, confirmUri, cancelUri string, opts ...GroupOpt) *Group

func (*Group) GetTranType

func (g *Group) GetTranType() consts.TransactionType

func (*Group) SetData

func (g *Group) SetData(data []byte) *Group

func (*Group) SetHeader

func (g *Group) SetHeader(data []byte) *Group

func (*Group) SetLevel

func (g *Group) SetLevel(level consts.Level) *Group

func (*Group) SetTimeout

func (g *Group) SetTimeout(second int) *Group

type GroupOpt

type GroupOpt func(group *Group)

type HandlerFn

type HandlerFn func(ctx context.Context) error

type Manger

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

func NewManger

func NewManger() *Manger

func (*Manger) AddGroups

func (m *Manger) AddGroups(groups ...*Group) *Manger

func (*Manger) AddNextWaitGroups

func (m *Manger) AddNextWaitGroups(groups ...*Group) *Manger

func (*Manger) Groups

func (m *Manger) Groups() []*Group

type Option

type Option func(options *Options)

func WithAfterFunc

func WithAfterFunc(after HandlerFn) Option

func WithBeforeFunc

func WithBeforeFunc(before HandlerFn) Option

func WithConnTimeout

func WithConnTimeout(seconds time.Duration) Option

func WithDiscovery

func WithDiscovery() Option

func WithGrpcDailOpts

func WithGrpcDailOpts(opts []grpc.DialOption) Option

type Options

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

type Protocol

type Protocol string
const (
	HTTP      Protocol = "http"
	GRPC      Protocol = "grpc"
	Undefined Protocol = "undefined"
)

Jump to

Keyboard shortcuts

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