Documentation ¶
Index ¶
- Constants
- func GenKey(tenant, functionName string) string
- func GetInitialPosition(pos string) (pulsar.SubscriptionInitialPosition, error)
- func GetKeyFromNames(tenant, functionName string) (string, error)
- func GetSubscriptionType(subType string) (pulsar.SubscriptionType, error)
- func IsURL(str string) bool
- func ValidateTopicConfig(top TopicConfig) (string, error)
- func ValidateWebhookConfig(whs []WebhookConfig) error
- type FunctionConfig
- type FunctionTopic
- type Status
- type TopicConfig
- type TopicKey
- type WebhookConfig
Constants ¶
const (
NonResumable = "NonResumable"
)
Variables ¶
This section is empty.
Functions ¶
func GetInitialPosition ¶
func GetInitialPosition(pos string) (pulsar.SubscriptionInitialPosition, error)
GetInitialPosition returns the initial position for subscription
func GetKeyFromNames ¶
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 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"` 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 ¶
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