model

package
v0.0.0-...-ec8dcbf Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2020 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NonResumable = "NonResumable"
)

Variables

This section is empty.

Functions

func GenKey

func GenKey(tenant, functionName string) string

GenKey generates a unique key based on pulsar url and topic full name

func GetInitialPosition

func GetInitialPosition(pos string) (pulsar.SubscriptionInitialPosition, error)

GetInitialPosition returns the initial position for subscription

func GetKeyFromNames

func GetKeyFromNames(tenant, functionName string) (string, error)

GetKeyFromNames generate topic key based on topic full name and pulsar url

func GetSubscriptionType

func GetSubscriptionType(subType string) (pulsar.SubscriptionType, error)

GetSubscriptionType converts string based subscription type to Pulsar subscription type

func IsURL

func IsURL(str string) bool

IsURL evaluates if this is PulsarURL

func ValidateTopicConfig

func ValidateTopicConfig(top TopicConfig) (string, error)

ValidateTopicConfig validates the TopicConfig and returns the key to identify this topic

func ValidateWebhookConfig

func ValidateWebhookConfig(whs []WebhookConfig) error

ValidateWebhookConfig validates WebhookConfig object I'd write explicit validation code rather than any off the shelf library, which are just DSL and sometime these library just like fit square peg in a round hole. Explicit validation has no dependency and very specific.

Types

type FunctionConfig

type FunctionConfig struct {
	Name             string        `json:"name"`
	ID               string        `json:"id"`
	Tenant           string        `json:"tenant"`
	FunctionStatus   Status        `json:"functionStatus"`
	FunctionFilePath string        `json:"functionFilePath"`
	LanguagePack     string        `json:"languagePack"`
	Parallelism      int           `json:"parallelism"`
	WebhookURLs      []string      `json:"webhookURLs"`
	InputTopic       FunctionTopic `json:"inputTopics"`
	OutputTopic      FunctionTopic `json:"outputTopics"`
	LogTopic         FunctionTopic `json:"logTopic"`
	TriggerType      string        `json:"triggerType"`
	Cron             string        `json:"cron"`
	CreatedAt        time.Time     `json:"createdAt"`
	UpdatedAt        time.Time     `json:"updatedAt"`
	DeletedAt        time.Time     `json:"deletedAt"`
}

FunctionConfig is the function configuration

type FunctionTopic

type FunctionTopic struct {
	TopicFullName    string `json:"topicFullName"`
	PulsarURL        string `json:"pulsarURL"`
	Token            string `json:"token"`
	Tenant           string `json:"tenant"`
	Key              string `json:"key"`
	Subscription     string `json:"subscription"`
	SubscriptionType string `json:"subscriptionType"`
	KeySharedPolicy  string `json:"keySharedPolicy"`
	InitialPosition  string `json:"initialPosition"`
}

FunctionTopic is the topic configurtion for function

type Status

type Status int

Status can be used for webhook status

const (
	// Deactivated is the beginning state
	Deactivated Status = iota
	// Activated is the only active state
	Activated
	// Suspended is the state between Activated and Deleted
	Suspended
	// Deleted is the end of state
	Deleted
)

state machine of webhook state

func StringToStatus

func StringToStatus(status string) Status

StringToStatus converts status in string to Status type

type TopicConfig

type TopicConfig struct {
	TopicFullName string
	PulsarURL     string
	Token         string
	Tenant        string
	Key           string
	Notes         string
	TopicStatus   Status
	Webhooks      []WebhookConfig
	CreatedAt     time.Time
	UpdatedAt     time.Time
}

TopicConfig - a configuraion for topic and its webhook configuration.

func NewTopicConfig

func NewTopicConfig(topicFullName, pulsarURL, token string) (TopicConfig, error)

NewTopicConfig creates a topic configuration struct.

type TopicKey

type TopicKey struct {
	TopicFullName string `json:"TopicFullName"`
	PulsarURL     string `json:"PulsarURL"`
}

TopicKey represents a struct to identify a topic

type WebhookConfig

type WebhookConfig struct {
	URL              string    `json:"url"`
	Headers          []string  `json:"headers"`
	Subscription     string    `json:"subscription"`
	SubscriptionType string    `json:"subscriptionType"`
	InitialPosition  string    `json:"initialPosition"`
	WebhookStatus    Status    `json:"webhookStatus"`
	CreatedAt        time.Time `json:"createdAt"`
	UpdatedAt        time.Time `json:"updatedAt"`
	DeletedAt        time.Time `json:"deletedAt"`
}

WebhookConfig - a configuration for webhook

func NewWebhookConfig

func NewWebhookConfig(URL string) WebhookConfig

NewWebhookConfig creates a new webhook config

Jump to

Keyboard shortcuts

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