socketsubscribe

package
v0.0.0-...-6e4d973 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var GlobalSock = &globalSock{
	mu:      &sync.Mutex{},
	sockMap: make(map[string]*sock),
}

Functions

func ContainsSocketActionType

func ContainsSocketActionType(types []string, actionType ...SocketActionType) bool

func ContainsSuccessTerm

func ContainsSuccessTerm(terms []string, term SuccessTerm) bool

func ContainsTermError

func ContainsTermError(conditions []string, termError ErrorTypeForTerm) bool

func NewSock

func NewSock(s *Socket, outputEnabled bool) *sock

func SocketConnect

func SocketConnect(
	ctx context.Context,
	ctr *app.Container,
	conf SocketConnectConfig,
	store *sync.Map,
	outputRoot string,
) error

func SocketConnectAndSubscribe

func SocketConnectAndSubscribe(
	ctx context.Context,
	ctr *app.Container,
	conf SocketConnectAndSubscribeConfig,
	store *sync.Map,
	outputRoot string,
) error

func SocketSubscribe

func SocketSubscribe(
	ctx context.Context,
	ctr *app.Container,
	conf SocketSubscribeConfig,
	store *sync.Map,
	selfLoopCount string,
	outputRoot string,
) error

Types

type BatchTestOutput

type BatchTestOutput struct {
	Enabled bool `yaml:"enabled"`
}

type DataTypeChan

type DataTypeChan int
const (
	DataTypeChanSuccessEvent DataTypeChan
	DataTypeChanFailEvent
	DataChanError
)

type ErrorTypeForTerm

type ErrorTypeForTerm string
const (
	ErrorTypeForTermParseError     ErrorTypeForTerm = "parse_error"
	ErrorTypeForTermUnmarshalError ErrorTypeForTerm = "unmarshal_error"
	ErrorTypeForTermReadError      ErrorTypeForTerm = "read_error"
	ErrorTypeForTermSendError      ErrorTypeForTerm = "send_error"
)

type SelfEventFilter

type SelfEventFilter struct {
	JMESPath *jmespath.JMESPath
}

type Socket

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

func NewSocket

func NewSocket(ctx context.Context, ctr *app.Container, msgHandler ws.EventResponseMessageHandleFunc) (*Socket, error)

func NewSocketWithSubscribeHandler

func NewSocketWithSubscribeHandler(
	ctx context.Context,
	ctr *app.Container,
	msgHandler ws.EventResponseMessageHandleFunc,
	subscribeHandler ws.SubscribeResponseMessageHandleFunc,
) (*Socket, error)

func (*Socket) Close

func (s *Socket) Close()

func (*Socket) Connect

func (s *Socket) Connect(ctx context.Context, ctr *app.Container, config ws.ConnectConfig) (<-chan ws.TerminateType, error)

func (*Socket) Subscribe

func (s *Socket) Subscribe(
	ctx context.Context,
	consumerID string,
	aggregateType ws.AggregateType,
	aggregateIDs []string,
	eventTypes []ws.EventType,
) error

type SocketActionType

type SocketActionType string
const (
	SocketActionTypeStore       SocketActionType = "store"
	SocketActionTypeOutput      SocketActionType = "output"
	SocketActionTypeUnsubscribe SocketActionType = "unsubscribe"
)

type SocketConnectAndSubscribeConfig

type SocketConnectAndSubscribeConfig struct {
	Type        string                             `yaml:"type"`
	Output      BatchTestOutput                    `yaml:"output"`
	Subscribes  []SocketSubscribeSubscribeConfig   `yaml:"subscribes"`
	Actions     []SocketSubscribeActionConfig      `yaml:"actions"`
	SuccessTerm []string                           `yaml:"successTerm"`
	Term        SocketSubscribeTermConditionConfig `yaml:"termCondition"`
}

type SocketConnectConfig

type SocketConnectConfig struct {
	Type        string                             `yaml:"type"`
	Output      BatchTestOutput                    `yaml:"output"`
	ID          string                             `yaml:"id"`
	SuccessTerm []string                           `yaml:"successTerm"`
	Term        SocketSubscribeTermConditionConfig `yaml:"termCondition"`
}

type SocketSubscribeActionConfig

type SocketSubscribeActionConfig struct {
	ID         string                            `yaml:"id"`
	Types      []string                          `yaml:"types"`
	EventTypes []string                          `yaml:"eventTypes"`
	Data       []SocketSubscribeActionDataConfig `yaml:"data"`
}

type SocketSubscribeActionDataConfig

type SocketSubscribeActionDataConfig struct {
	Key      string `yaml:"key"`
	JMESPath string `yaml:"jmesPath"`
	OnNil    string `yaml:"onNil"`
	OnError  string `yaml:"onError"`
}

type SocketSubscribeConfig

type SocketSubscribeConfig struct {
	Type                        string                               `yaml:"type"`
	Output                      BatchTestOutput                      `yaml:"output"`
	ID                          string                               `yaml:"id"`
	ConnectID                   string                               `yaml:"connectId"`
	SelfEventFilter             SocketSubscribeSelfEventFilterConfig `yaml:"selfEventFilter"`
	Subscribe                   SocketSubscribeSubscribeConfig       `yaml:"subscribe"`
	SuccessUnsubscribeActionIDs []string                             `yaml:"successUnsubscribeActionIds"`
	Actions                     []SocketSubscribeActionConfig        `yaml:"actions"`
}

type SocketSubscribeSelfEventFilterConfig

type SocketSubscribeSelfEventFilterConfig struct {
	JMESPath string `yaml:"jmesPath"`
}

type SocketSubscribeSubscribeConfig

type SocketSubscribeSubscribeConfig struct {
	AggregateType string   `yaml:"aggregateType"`
	AggregateId   []string `yaml:"aggregateId"`
	EventTypes    []string `yaml:"eventTypes"`
}

type SocketSubscribeTermConditionConfig

type SocketSubscribeTermConditionConfig struct {
	Time  *string                                   `yaml:"time"`
	Error []string                                  `yaml:"error"`
	Event []SocketSubscribeTermConditionEventConfig `yaml:"event"`
}

type SocketSubscribeTermConditionEventConfig

type SocketSubscribeTermConditionEventConfig struct {
	Types    []string `yaml:"types"`
	Success  bool     `yaml:"success"`
	JMESPath string   `yaml:"jmesPath"`
}

type SuccessTerm

type SuccessTerm string
const (
	SuccessTermClose SuccessTerm = "close"
	SuccessTermTime  SuccessTerm = "time"
	SuccessTermError SuccessTerm = "error"
	SuccessTermEvent SuccessTerm = "event"
	SuccessTermData  SuccessTerm = "data"
)

Jump to

Keyboard shortcuts

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