jetflow

package module
v0.0.0-...-e0b593a Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2024 License: Apache-2.0 Imports: 11 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ContextAddInvolvedOperator

func ContextAddInvolvedOperator(ctx context.Context, name, id string) context.Context

ContextAddInvolvedOperator mutates context's set of involved operators.

func ContextWithInvolvedOperators

func ContextWithInvolvedOperators(ctx context.Context, operators map[string]map[string]bool) context.Context

func ContextWithOperationID

func ContextWithOperationID(ctx context.Context, operationID string) context.Context

func InvolvedOperatorsFromContext

func InvolvedOperatorsFromContext(ctx context.Context) map[string]map[string]bool

func TransactionIDFromContext

func TransactionIDFromContext(ctx context.Context, callID string) string

Types

type Client

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

func NewClient

func NewClient(mapping ProxyFactoryMapping, publisher Publisher) *Client

func (*Client) Call

func (c *Client) Call(ctx context.Context, call *Request) (res []byte, err error)

func (*Client) Find

func (c *Client) Find(ctx context.Context, id string, operator interface{}) error

type Executor

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

func NewExecutor

func NewExecutor(storage Storage, client OperatorClient) *Executor

func (*Executor) Handle

func (w *Executor) Handle(ctx context.Context, req *Request) *Response

type HandlerFactory

type HandlerFactory func(id string) OperatorHandler

type HandlerFactoryMapping

type HandlerFactoryMapping map[string]HandlerFactory

ProxyFactoryMapping maps type names to OperatorFactories.

type Method

type Method string
const (
	MethodPrepare  Method = "__PREPARE__"
	MethodCommit   Method = "__COMMIT__"
	MethodRollback Method = "__ROLLBACK__"
)

type Operator

type Operator interface {
	ID() string
}

Operator is the minimal interface for all operators.

type OperatorClient

type OperatorClient interface {
	Find(ctx context.Context, id string, operator interface{}) error
	Call(context.Context, *Request) (res []byte, err error)
}

type OperatorHandler

type OperatorHandler interface {
	Handle(context.Context, OperatorClient, *Request) ([]byte, error)
}

OperatorHandler handles calls to the methods of an operator.

It will convert an OperatorCall to a method call and convert the result to a Result struct.

type ProxyFactory

type ProxyFactory func(id string, client OperatorClient) Operator

ProxyFactory instantiates a OperatorProxy value.

Used by the OperatorClient to instantiate an operator to an OperatorProxy, so method calls can be proxied to the actual implementation.

type ProxyFactoryMapping

type ProxyFactoryMapping map[string]ProxyFactory

ProxyFactoryMapping maps type names to OperatorFactories.

type Publisher

type Publisher interface {
	Publish(context.Context, *Request) (chan *Response, error)
}

type Request

type Request struct {
	TransactionID string `json:"o"`
	RequestID     string `json:"r"`

	TypeName   string `json:"n"`
	InstanceID string `json:"i"`
	Method     string `json:"m"`
	Args       []byte `json:"a"`
}

func (*Request) Response

func (r *Request) Response(ctx context.Context, values []byte, err error) *Response

func (*Request) String

func (r *Request) String() string

String returns a string representation of the request.

type RequestHandler

type RequestHandler interface {
	Handle(context.Context, *Request) *Response
}

type Response

type Response struct {
	RequestID         string
	InvolvedOperators map[string]map[string]bool

	Values []byte
	Error  error
}

func (Response) MarshalJSON

func (r Response) MarshalJSON() ([]byte, error)

func (*Response) UnmarshalJSON

func (r *Response) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler

type Storage

type Storage interface {
	Get(context.Context, *Request) (OperatorHandler, error)
	Prepare(context.Context, *Request) error
	Commit(context.Context, *Request) error
	Rollback(context.Context, *Request) error
}

Directories

Path Synopsis
cmd
examples
simplebank Module
storage
transport

Jump to

Keyboard shortcuts

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