protocol

package
v0.0.0-...-f80b70b Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2022 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultCloudEventType is the default event type for an pulse published event
	DefaultCloudEventType = "com.pulse.event.sent"
	// CloudEventsSpecVersion is the specversion used by pulse for the cloud events implementation
	CloudEventsSpecVersion = "1.0"
	//ContentType is the Cloud Events HTTP content type
	ContentType = "application/cloudevents+json"
	// DefaultCloudEventSource is the default event source
	DefaultCloudEventSource = "pulse"
	// DefaultCloudEventWebhook
	DefaultCloudEventWebhook = ""
)

Variables

This section is empty.

Functions

This section is empty.

Types

type CloudEventsEnvelope

type CloudEventsEnvelope struct {
	ID          string `json:"id"`
	Source      string `json:"source"`
	Type        string `json:"type"`
	SpecVersion string `json:"specversion"`
	// See DataContentType https://tools.ietf.org/html/rfc2046
	DataContentType string `json:"datacontenttype"`
	Data            []byte `json:"data"`
	Topic           string `json:"topic"`
	WebhookURL      string `json:"webhookUrl"`
	OrderingKey     string `json:"orderingKey"` // for test, order id, would be ordered consume by the consumer.

	// Logic is represents the fields that don't need initialize by the protocol producer.
	Size int
	// DeliveryAttempt is the number of times a protocol has been delivered.
	// This is part of the dead lettering feature that forwards messages that
	// fail to be processed (from nack/ack deadline timeout) to a dead letter topic.
	// If dead lettering is enabled, this will be set on all attempts, starting
	// with value 1. Otherwise, the value will be nil.
	// This field is read-only.
	DeliveryAttempt *int

	DoneFunc func(string, bool) `json:"-"`
	// contains filtered or unexported fields
}

CloudEventsEnvelope describes the Dapr implementation of the Cloud Events spec Spec details: https://github.com/cloudevents/spec/blob/master/spec.md

func NewCloudEventsEnvelope

func NewCloudEventsEnvelope(id, source, datacontentType, eventType, topic, webhook, orderingKey string, data []byte) (*CloudEventsEnvelope, error)

NewCloudEventsEnvelope returns CloudEventsEnvelope from data or a new one when data content was not

func NewSimpleByteMessage

func NewSimpleByteMessage(data []byte) *CloudEventsEnvelope

NewSimpleByteMessage -

func (*CloudEventsEnvelope) Ack

func (m *CloudEventsEnvelope) Ack()

Ack indicates successful processing of a Message passed to the Subscriber.Receive callback. It should not be called on any other Message value. If protocol acknowledgement fails, the Message will be redelivered. Client code must call Ack or Nack when finished for each received Message. Calls to Ack or Nack have no effect after the first call.

func (*CloudEventsEnvelope) Nack

func (m *CloudEventsEnvelope) Nack()

Nack indicates that the client will not or cannot process a Message passed to the Subscriber.Receive callback. It should not be called on any other Message value. Nack will result in the Message being redelivered more quickly than if it were allowed to expire. Client code must call Ack or Nack when finished for each received Message. Calls to Ack or Nack have no effect after the first call.

func (*CloudEventsEnvelope) String

func (m *CloudEventsEnvelope) String() string

hint: now protocol string just print the event

type Message

type Message struct {
	UUID string
	Data []byte

	Topic       string
	OrderingKey string
}

func NewMessage

func NewMessage(topic, orderingKey string, data []byte) *Message

func (*Message) Do

func (m *Message) Do(fn visitor.DoFunc) error

type Metadata

type Metadata struct {
	Properties map[string]string
	Features   []string
}

func NewMetadata

func NewMetadata() Metadata

func (*Metadata) Clone

func (m *Metadata) Clone() *Metadata

func (*Metadata) GetDriverName

func (m *Metadata) GetDriverName() string

if driverName is empty, use default local driver. which couldn't cross process

func (*Metadata) SetDriver

func (m *Metadata) SetDriver(driverName string)

type PublishRequest

type PublishRequest struct {
	Data       []byte            `json:"data"`
	PubsubName string            `json:"pubsubname"`
	Topic      string            `json:"topic"`
	Metadata   map[string]string `json:"metadata"`

	OrderingKey string `json:"orderingkey"`
}

PublishRequest is the request to publish a message

type SubscribeRequest

type SubscribeRequest struct {
	Topic    string   `json:"topic"`
	Metadata Metadata `json:"metadata"`
}

SubscribeRequest is the request to subscribe to a topic

func NewSubscribeRequest

func NewSubscribeRequest(topic string, metadata Metadata) *SubscribeRequest

Directories

Path Synopsis
gob
proto
Package proto defines the protobuf codec.
Package proto defines the protobuf codec.
todo: add ratelimit from go-kit
todo: add ratelimit from go-kit

Jump to

Keyboard shortcuts

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