psub

package module
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewBoiler

func NewBoiler(c *pubsub.Client) boilerplate

Types

type Message

type Message struct {
	*pubsub.Message
}

func NewMessage

func NewMessage(data []byte) *Message

func (*Message) Get

func (m *Message) Get(key string) string

func (*Message) GetFeature

func (m *Message) GetFeature() string

func (*Message) GetVersion

func (m *Message) GetVersion() int

func (*Message) SetDeliveryOrder

func (m *Message) SetDeliveryOrder(order string) *Message

func (*Message) SetFeature

func (m *Message) SetFeature(f string) *Message

func (*Message) SetStr

func (m *Message) SetStr(key, value string) *Message

func (*Message) SetVersion

func (m *Message) SetVersion(v int) *Message

type MsgHandler

type MsgHandler func(context.Context, *pubsub.Message) error

type PsubConnection

type PsubConnection struct {
	*pubsub.Client
	// contains filtered or unexported fields
}
var Connection *PsubConnection // for singleton usage

func Connect

func Connect(ctx context.Context, projectID string, opts ...option.ClientOption) (*PsubConnection, error)

func (*PsubConnection) Log

func (c *PsubConnection) Log(a ...any)

func (*PsubConnection) Publish

func (c *PsubConnection) Publish(ctx context.Context, topicID string, message Message) error

func (*PsubConnection) PublishRaw

func (c *PsubConnection) PublishRaw(ctx context.Context, topicID string, data []byte) error

func (*PsubConnection) SetLog

func (c *PsubConnection) SetLog(isLog bool)

func (*PsubConnection) SettingTopic

func (c *PsubConnection) SettingTopic(ctx context.Context, topicID string, setting pubsub.PublishSettings)

func (*PsubConnection) Subscribe

func (c *PsubConnection) Subscribe(ctx context.Context, subID string, fn MsgHandler, opts ...*SubscribeOption) (*Subscriber, error)

Subscribe to the subscription

func (*PsubConnection) Upsert

func (c *PsubConnection) Upsert(ctx context.Context, cmd UpsertCmd) error

func (*PsubConnection) UpsertMany

func (c *PsubConnection) UpsertMany(ctx context.Context, psubs []UpsertCmd) error

func (*PsubConnection) UpsertSubscriptions

func (c *PsubConnection) UpsertSubscriptions(ctx context.Context, cmd SubsInfo) error

func (*PsubConnection) UpsertTopic

func (c *PsubConnection) UpsertTopic(ctx context.Context, topicID string) (*pubsub.Topic, error)

type Sub

type Sub struct {
	ID     string
	Config *pubsub.SubscriptionConfig
}

type SubsInfo

type SubsInfo struct {
	Subs          []Sub
	DefaultConfig pubsub.SubscriptionConfig
}

type SubscribeOption

type SubscribeOption struct {
	ACKErr          *bool
	RetrySubscribe  *bool                                                // default: true
	IsLog           *bool                                                //default: false
	DeduplicateFunc func(context.Context, *pubsub.Message) (bool, error) // return true if message duplicated
	ACKHook         func(*pubsub.Message)
	NACKHook        func(*pubsub.Message)
	ReceiveSettings *pubsub.ReceiveSettings
}

func NewSubscribeOption

func NewSubscribeOption() *SubscribeOption

func (*SubscribeOption) SetACKAll added in v1.0.1

func (s *SubscribeOption) SetACKAll(ack bool) *SubscribeOption

func (*SubscribeOption) SetACKHook added in v1.0.1

func (s *SubscribeOption) SetACKHook(f func(*pubsub.Message)) *SubscribeOption

SetACKHook not apply for deduplicate ack()

func (*SubscribeOption) SetDeduplicate added in v1.0.1

func (s *SubscribeOption) SetDeduplicate(isDuplicateFunc func(context.Context, *pubsub.Message) (bool, error)) *SubscribeOption

func (*SubscribeOption) SetIsLog added in v1.0.2

func (s *SubscribeOption) SetIsLog(isLog bool) *SubscribeOption

func (*SubscribeOption) SetNACKHook added in v1.0.1

func (s *SubscribeOption) SetNACKHook(f func(*pubsub.Message)) *SubscribeOption

func (*SubscribeOption) SetReceiveSettings added in v1.0.1

func (s *SubscribeOption) SetReceiveSettings(settings pubsub.ReceiveSettings) *SubscribeOption

func (*SubscribeOption) SetRetry added in v1.0.1

func (s *SubscribeOption) SetRetry(retry bool) *SubscribeOption

type Subscriber

type Subscriber struct {
	ID         string
	Sub        *pubsub.Subscription
	CancelFunc context.CancelFunc
	// contains filtered or unexported fields
}

type UpsertCmd

type UpsertCmd struct {
	TopicID    string
	UpsertSubs SubsInfo
}

Jump to

Keyboard shortcuts

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