transco

package module
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: May 14, 2022 License: MIT Imports: 9 Imported by: 0

README

transco

Transcoordinator go-client library

Documentation

Index

Constants

View Source
const (
	SchemeHttp       = "http"
	SchemeHttps      = "https"
	DefaultPort      = "8000"
	SysPrefixApiPath = "api/sys"
	MaxRetry         = 10
)

Scheme constants

View Source
const (
	DefaultUri      = "http://transcoorditor:8000"
	V1PrefixApiPath = "api/v1"
)

Variables

View Source
var (
	ErrNotLeader       = NewRetryableError(errors.New("not leader"))
	ErrNoNodeAvailable = errors.New("no node available")
)

Functions

func IsRetryableErr

func IsRetryableErr(err error) bool

Types

type Client

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

func New

func New(uri string) (*Client, error)

func (*Client) AbortSession

func (c *Client) AbortSession(sessionId string) (*Session, error)

func (*Client) CommitSession

func (c *Client) CommitSession(sessionId string) (*Session, error)

func (*Client) JoinSession

func (c *Client) JoinSession(sessionId string, body *ParticipantJoinBody) (*Participant, error)

func (*Client) PartialCommit

func (c *Client) PartialCommit(sessionId string, body *ParticipantCommit) (*Participant, error)

func (*Client) SessionFromId

func (c *Client) SessionFromId(sessionId string) (*Session, error)

func (*Client) StartSession

func (c *Client) StartSession() (*Session, error)

type Connection

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

func NewConn

func NewConn(uri string) (*Connection, error)

func (*Connection) Connect

func (c *Connection) Connect() error

func (*Connection) GetLeader

func (c *Connection) GetLeader() *node

func (*Connection) GetNodes

func (c *Connection) GetNodes() []*node

func (*Connection) GetRsConf

func (c *Connection) GetRsConf() *rsConfiguration

func (*Connection) Leader

func (c *Connection) Leader() *node

type ErrResponse

type ErrResponse struct {
	Err string `json:"err"`
	Msg string `json:"msg"`
}

type OkResponse

type OkResponse struct {
	Data interface{} `json:"data"`
}

type Participant

type Participant struct {
	Id        int64  `json:"id"`
	SessionId string `json:"sessionId"`

	ClientId         string             `json:"clientId"`
	RequestId        string             `json:"requestId"`
	State            string             `json:"state"`
	CompensateAction *ParticipantAction `json:"compensateAction,omitempty"`
	CompleteAction   *ParticipantAction `json:"completeAction,omitempty"`
	UpdatedAt        *time.Time         `json:"updatedAt,omitempty"`
	CreatedAt        *time.Time         `json:"createdAt"`
	// contains filtered or unexported fields
}

func (*Participant) PartialCommit

func (p *Participant) PartialCommit(compensate *ParticipantAction, complete *ParticipantAction) error

type ParticipantAction

type ParticipantAction struct {
	Data         interface{}               `json:"data"`
	Uri          *string                   `json:"uri"`
	Status       string                    `json:"status"`
	Results      []*map[string]interface{} `json:"results"`
	InvokedCount int                       `json:"invokedCount"`
}

type ParticipantCommit

type ParticipantCommit struct {
	Id         int64              `json:"participantId"`
	Compensate *ParticipantAction `json:"compensate"`
	Complete   *ParticipantAction `json:"complete"`
}

type ParticipantJoinBody

type ParticipantJoinBody struct {
	ClientId  string `json:"clientId"`
	RequestId string `json:"requestId"`
}

type RequestFunc

type RequestFunc func(req *RestRequest) (*resty.Response, error)

type Rest

type Rest struct {
	*resty.Client
}

func NewRest

func NewRest() *Rest

type RestRequest

type RestRequest struct {
	*resty.Request
}

func (*RestRequest) SetResult

func (req *RestRequest) SetResult(result interface{}) *RestRequest

type RetryableError

type RetryableError struct {
	Err error
}

func NewRetryableError

func NewRetryableError(err error) *RetryableError

func (*RetryableError) Error

func (e *RetryableError) Error() string

type Session

type Session struct {
	Id string `json:"id"`

	State           string     `json:"state"`
	Timeout         int        `json:"timeout"`
	UpdatedAt       *time.Time `json:"updatedAt,omitempty"`
	StartedAt       *time.Time `json:"startedAt,omitempty"`
	CreatedAt       *time.Time `json:"createdAt,omitempty"`
	Errors          []string   `json:"errors,omitempty"`
	Retries         int        `json:"retries"`
	TerminateReason string     `json:"terminateReason,omitempty"`
	// contains filtered or unexported fields
}

func (*Session) AbortSession

func (s *Session) AbortSession() error

func (*Session) CommitSession

func (s *Session) CommitSession() error

func (*Session) JoinSession

func (s *Session) JoinSession(body *ParticipantJoinBody) (*Participant, error)

Jump to

Keyboard shortcuts

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