azureeventgrid

package
v1.10.0 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2026 License: MIT Imports: 39 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

Azure Event Grid

Parity grade: B · SDK azure-sdk-for-go/sdk/messaging/eventgrid/azeventgrid@v1.0.0 · last audited 2026-10-21 (be2302298)

Coverage

Metric Value
PARITY entries audited 10 (9 ok, 1 partial)
Feature families 10 (10 ok)
Known gaps 8
Deferred items 0
Resource leaks clean
Known gaps
  • System topics, partner topics and partner configurations are not implemented (no Microsoft.EventGrid/systemTopics ARM resource with source and topicType). Of the emulated sources only azureblob emits events (BlobCreated, BlobDeleted); azureservicebus and azurekeyvault publish none.
  • Delivery with managed identity and AAD bearer validation are not implemented.
  • Namespace topic subscriptions do not support dead-letter destinations or webhook push delivery.
  • Resource-scope events cover BlobCreated, BlobDeleted, BlobTierChanged and AsyncOperationInitiated; Service Bus and Key Vault emit nothing.
  • System topics, partner topics and partner configurations are not implemented: services/azurearm has no Microsoft.EventGrid/systemTopics resource type, and azureservicebus and azurekeyvault expose no event hook, so only azureblob emits events.
  • Managed-identity delivery (deliveryWithResourceIdentity) and AAD bearer validation of publish requests are not implemented (RBAC is out of scope).
  • Namespace topic subscriptions have no dead-letter destination, push (webhook) delivery mode or ARM-level topic spaces.
  • Resource-scope event subscriptions receive Microsoft.Storage.BlobCreated, BlobDeleted, BlobTierChanged and AsyncOperationInitiated for a storage account scope; BlobRenamed and DirectoryCreated/Deleted are not emitted (no hierarchical namespace), Service Bus and Key Vault emit nothing, and Microsoft.Resources events cover only the Succeeded outcomes (write, delete, action) of ARM lifecycle events.

More

Documentation

Overview

Package azureeventgrid emulates Azure Event Grid: custom topics with event subscriptions delivering to webhooks, Service Bus, Event Hubs and Storage queues (with retries and blob dead-lettering), and namespace topics with pull delivery. State is shared with the ARM plane; the HTTPS data plane serves the official publisher and namespace SDKs. See PARITY.md.

Index

Constants

View Source
const (
	EventResourceWriteSuccess  = "Microsoft.Resources.ResourceWriteSuccess"
	EventResourceDeleteSuccess = "Microsoft.Resources.ResourceDeleteSuccess"
	EventResourceActionSuccess = "Microsoft.Resources.ResourceActionSuccess"
)

Azure Resource Manager event types and schema versions.

View Source
const (
	SchemaEventGrid  = "EventGridSchema"
	SchemaCloudEvent = "CloudEventSchemaV1_0"
	// SchemaCustom is a topic input schema that maps arbitrary JSON onto the Event Grid schema.
	SchemaCustom = "CustomEventSchema"
	// SchemaCustomInput is the delivery schema that hands subscribers the originally published payload.
	SchemaCustomInput = "CustomInputSchema"

	EndpointWebHook      = "WebHook"
	EndpointServiceBusQ  = "ServiceBusQueue"
	EndpointServiceBusT  = "ServiceBusTopic"
	EndpointEventHub     = "EventHub"
	EndpointStorageQueue = "StorageQueue"
	EndpointStorageBlob  = "StorageBlob"
	EndpointAzureFunc    = "AzureFunction"
	EndpointHybridConn   = "HybridConnection"
	EndpointPartner      = "PartnerDestination"

	StateSucceeded      = "Succeeded"
	StateAwaitingManual = "AwaitingManualAction"

	DefaultMaxDeliveryAttempts = 30
	DefaultEventTTLMinutes     = 1440
)

Event schemas and endpoint types.

View Source
const (
	// MaxRequestBytes is the largest publish request body accepted (Event Grid's 1 MB limit).
	MaxRequestBytes = 1 << 20
	// MaxEventsPerRequest bounds the events of one publish request.
	MaxEventsPerRequest = 5000
)
View Source
const DefaultPort = 10007

DefaultPort is the Event Grid HTTPS data-plane port.

View Source
const (

	// MaxReceiveEvents is the largest maxEvents a receive call honours.
	MaxReceiveEvents = 100
)

Variables

View Source
var (
	ErrTopicNotFound          = errors.New("azureeventgrid: topic not found")
	ErrSubscriptionNotFound   = errors.New("azureeventgrid: event subscription not found")
	ErrDomainNotFound         = errors.New("azureeventgrid: domain not found")
	ErrDomainTopicNotFound    = errors.New("azureeventgrid: domain topic not found")
	ErrNamespaceNotFound      = errors.New("azureeventgrid: namespace not found")
	ErrNamespaceTopicNotFound = errors.New("azureeventgrid: namespace topic not found")
	ErrPullSubNotFound        = errors.New("azureeventgrid: namespace topic subscription not found")
	ErrInvalidName            = errors.New("azureeventgrid: invalid entity name")
	ErrInvalidSpec            = errors.New("azureeventgrid: invalid event subscription")
	ErrWebhookValidation      = errors.New("azureeventgrid: webhook validation handshake failed")
	ErrTargetUnavailable      = errors.New("azureeventgrid: delivery target is not wired")
	ErrInvalidEvent           = errors.New("azureeventgrid: invalid event")
	ErrTooManyEvents          = errors.New("azureeventgrid: too many events in one request")
	ErrNilAppContext          = errors.New("azureeventgrid: nil app context")
	ErrAmbiguousTopic         = errors.New("azureeventgrid: cannot determine the topic of the request")
	ErrBadLockToken           = errors.New("azureeventgrid: lock token is invalid or expired")
)

Backend errors.

View Source
var ErrUnauthorized = errors.New("azureeventgrid: unauthorized")

ErrUnauthorized is returned when validation is on and no credential matches.

Functions

func SignToken

func SignToken(resource string, expiry time.Time, key string) string

SignToken builds an Event Grid SAS token for resource, valid until expiry.

Types

type AdvancedFilter

type AdvancedFilter struct {
	Value        any    `json:"value,omitempty"`
	OperatorType string `json:"operatorType"`
	Key          string `json:"key,omitempty"`
	Values       []any  `json:"values,omitempty"`
}

AdvancedFilter is one entry of filter.advancedFilters.

type ConfigProvider

type ConfigProvider interface {
	GetAzureEventGridSettings() Settings
}

ConfigProvider extracts the Event Grid settings from the AppContext config.

type Destination

type Destination struct {
	Properties   map[string]any `json:"properties,omitempty"`
	EndpointType string         `json:"endpointType"`
}

Destination is a delivery or dead-letter endpoint in ARM wire shape.

type DomainInfo

type DomainInfo struct {
	CreatedAt   time.Time
	Name        string
	ResourceID  string
	InputSchema string
	AutoCreate  bool
	AutoDelete  bool
}

DomainInfo is the exported view of a domain.

type DomainTopicInfo

type DomainTopicInfo struct {
	CreatedAt time.Time
	Name      string
}

DomainTopicInfo is the exported view of a domain topic.

type Event

type Event struct {
	Fields map[string]any
	ID     string
	Raw    jsontext.Value
	// Original is the published payload of a custom-schema event (Raw is its Event Grid form).
	Original jsontext.Value
}

Event is one validated event: its raw JSON, decoded form and ID.

func ParseCustomEvents

func ParseCustomEvents(body []byte) ([]Event, error)

ParseCustomEvents decodes a publish body for a CustomEventSchema topic: any JSON object is an event.

func ParseEvents

func ParseEvents(body []byte, schema string) ([]Event, error)

ParseEvents decodes a publish body (a JSON array or a single object) and validates every event against the schema.

type Filter

type Filter struct {
	SubjectBeginsWith               string           `json:"subjectBeginsWith"`
	SubjectEndsWith                 string           `json:"subjectEndsWith"`
	IncludedEventTypes              []string         `json:"includedEventTypes,omitempty"`
	AdvancedFilters                 []AdvancedFilter `json:"advancedFilters,omitempty"`
	IsSubjectCaseSensitive          bool             `json:"isSubjectCaseSensitive"`
	EnableAdvancedFilteringOnArrays bool             `json:"enableAdvancedFilteringOnArrays,omitempty"`
}

Filter selects the events an event subscription receives.

func (Filter) Matches

func (f Filter) Matches(ev map[string]any) bool

Matches reports whether the event passes the basic and advanced filters.

type Handler

type Handler struct {
	Backend *InMemoryBackend

	Settings Settings
	Port     int
	// contains filtered or unexported fields
}

Handler owns the HTTPS listener and the delivery worker.

func NewHandler

func NewHandler(backend *InMemoryBackend, settings Settings) *Handler

NewHandler returns a Handler over backend.

func (*Handler) ExtractOperation

func (h *Handler) ExtractOperation(c *echo.Context) string

ExtractOperation implements service.Service.

func (*Handler) ExtractResource

func (h *Handler) ExtractResource(c *echo.Context) string

ExtractResource implements service.Service.

func (*Handler) GetSupportedOperations

func (h *Handler) GetSupportedOperations() []string

GetSupportedOperations implements service.Service.

func (*Handler) Handler

func (h *Handler) Handler() echo.HandlerFunc

Handler returns the echo handler of the HTTPS listener.

func (*Handler) MatchPriority

func (h *Handler) MatchPriority() int

MatchPriority implements service.Registerable.

func (*Handler) Name

func (h *Handler) Name() string

Name implements service.Service.

func (*Handler) Reset

func (h *Handler) Reset()

Reset implements service.Resettable.

func (*Handler) Restore

func (h *Handler) Restore(ctx context.Context, data []byte) error

Restore implements persistence.Persistable by delegating to the backend.

func (*Handler) RouteMatcher

func (h *Handler) RouteMatcher() service.Matcher

RouteMatcher never matches: Event Grid listens on its own port.

func (*Handler) Shutdown

func (h *Handler) Shutdown(ctx context.Context)

Shutdown implements service.Shutdowner.

func (*Handler) Snapshot

func (h *Handler) Snapshot(ctx context.Context) []byte

Snapshot implements persistence.Persistable by delegating to the backend.

func (*Handler) StartWorker

func (h *Handler) StartWorker(ctx context.Context) error

StartWorker binds the HTTPS listener and starts the delivery worker.

type InMemoryBackend

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

InMemoryBackend is the Event Grid state shared by the ARM and data planes.

func NewInMemoryBackend

func NewInMemoryBackend() *InMemoryBackend

NewInMemoryBackend returns an empty backend using the wall clock.

func (*InMemoryBackend) ARMScopes

func (b *InMemoryBackend) ARMScopes() []ScopeSubscriptions

ARMScopes returns the Azure Resource Manager scopes that own event subscriptions, sorted by ID.

func (*InMemoryBackend) Acknowledge

func (b *InMemoryBackend) Acknowledge(ns, topicName, sub string, tokens []string) ([]string, []LockFailure, error)

Acknowledge removes the locked events.

func (*InMemoryBackend) ConfirmValidation

func (b *InMemoryBackend) ConfirmValidation(code string) bool

ConfirmValidation completes a manual webhook validation started by a validationUrl GET.

func (*InMemoryBackend) DeleteDomain

func (b *InMemoryBackend) DeleteDomain(name string) error

DeleteDomain removes a domain with its topics and event subscriptions.

func (*InMemoryBackend) DeleteDomainTopic

func (b *InMemoryBackend) DeleteDomainTopic(domainName, name string) error

DeleteDomainTopic removes a domain topic and its event subscriptions.

func (*InMemoryBackend) DeleteNamespace

func (b *InMemoryBackend) DeleteNamespace(name string) error

DeleteNamespace removes a namespace with its topics.

func (*InMemoryBackend) DeleteNamespaceTopic

func (b *InMemoryBackend) DeleteNamespaceTopic(nsName, name string) error

DeleteNamespaceTopic removes a namespace topic and its subscriptions.

func (*InMemoryBackend) DeletePullSubscription

func (b *InMemoryBackend) DeletePullSubscription(ns, topicName, name string) error

DeletePullSubscription removes a namespace topic subscription.

func (*InMemoryBackend) DeleteScopedSubscription

func (b *InMemoryBackend) DeleteScopedSubscription(sc Scope, name string) error

DeleteScopedSubscription removes an event subscription and its undelivered events; the last subscription of a domain topic also removes the topic when the domain auto-deletes topics.

func (*InMemoryBackend) DeleteSubscription

func (b *InMemoryBackend) DeleteSubscription(topicName, name string) error

DeleteSubscription removes a custom topic's event subscription and its undelivered events.

func (*InMemoryBackend) DeleteTopic

func (b *InMemoryBackend) DeleteTopic(name string) error

DeleteTopic removes a custom topic and its event subscriptions.

func (*InMemoryBackend) DeliveryAttributes

func (b *InMemoryBackend) DeliveryAttributes(sc Scope, name string) ([]map[string]any, error)

DeliveryAttributes returns an event subscription's delivery attribute mappings with secret values included (getDeliveryAttributes).

func (*InMemoryBackend) Domain

func (b *InMemoryBackend) Domain(name string) (DomainInfo, error)

Domain returns the domain.

func (*InMemoryBackend) DomainKeys

func (b *InMemoryBackend) DomainKeys(name string) (Keys, error)

DomainKeys returns the domain's access keys.

func (*InMemoryBackend) DomainNames

func (b *InMemoryBackend) DomainNames() []string

DomainNames returns the domain names sorted.

func (*InMemoryBackend) DomainTopic

func (b *InMemoryBackend) DomainTopic(domainName, name string) (DomainTopicInfo, error)

DomainTopic returns a domain topic.

func (*InMemoryBackend) DomainTopics

func (b *InMemoryBackend) DomainTopics(domainName string) ([]DomainTopicInfo, error)

DomainTopics lists a domain's topics sorted by name.

func (*InMemoryBackend) FullURL

func (b *InMemoryBackend) FullURL(topicName, name string) (string, error)

FullURL returns the complete webhook endpoint URL of a custom topic's event subscription.

func (*InMemoryBackend) NamespaceExists

func (b *InMemoryBackend) NamespaceExists(name string) bool

NamespaceExists reports whether the namespace exists.

func (*InMemoryBackend) NamespaceKeys

func (b *InMemoryBackend) NamespaceKeys(name string) (Keys, error)

NamespaceKeys returns the namespace's access keys.

func (*InMemoryBackend) NamespaceNames

func (b *InMemoryBackend) NamespaceNames() []string

NamespaceNames returns the namespace names sorted.

func (*InMemoryBackend) NamespaceTopicCreated

func (b *InMemoryBackend) NamespaceTopicCreated(nsName, name string) (time.Time, error)

NamespaceTopicCreated returns a namespace topic's creation time.

func (*InMemoryBackend) NamespaceTopicNames

func (b *InMemoryBackend) NamespaceTopicNames(ns string) ([]string, error)

NamespaceTopicNames returns a namespace's topic names sorted.

func (*InMemoryBackend) PatchScopedSubscription

func (b *InMemoryBackend) PatchScopedSubscription(
	ctx context.Context, sc Scope, name string, patch map[string]any,
) (map[string]any, error)

PatchScopedSubscription applies an EventSubscriptionUpdateParameters body to an existing event subscription and returns its ARM properties. Only the supplied members change; the merged result is validated exactly as a PUT.

func (*InMemoryBackend) Publish

func (b *InMemoryBackend) Publish(topicName string, events []Event) error

Publish fans events out to the matching event subscriptions of a topic.

func (*InMemoryBackend) PublishDomain

func (b *InMemoryBackend) PublishDomain(domainName string, events []Event) error

PublishDomain fans events out to the subscriptions of the domain and of the domain topic each event names (EventGrid schema: "topic"; CloudEvents: "source"). Events for a topic without a domain topic reach only domain-scope subscriptions.

func (*InMemoryBackend) PublishNamespace

func (b *InMemoryBackend) PublishNamespace(ns, topicName string, events []Event) error

PublishNamespace fans CloudEvents out to the matching subscriptions of a namespace topic.

func (*InMemoryBackend) PublishResourceEvent

func (b *InMemoryBackend) PublishResourceEvent(ev ResourceEvent)

PublishResourceEvent delivers an Azure Resource Manager event to the event subscriptions of its Azure subscription and, when it has one, its resource group.

func (*InMemoryBackend) PublishStorageEvent

func (b *InMemoryBackend) PublishStorageEvent(ev StorageEvent)

PublishStorageEvent delivers a blob event to the event subscriptions of the storage account's resource scope.

func (*InMemoryBackend) PullSubscription

func (b *InMemoryBackend) PullSubscription(ns, topicName, name string) (map[string]any, time.Time, error)

PullSubscription returns the ARM properties and creation time of a namespace topic subscription.

func (*InMemoryBackend) PullSubscriptionNames

func (b *InMemoryBackend) PullSubscriptionNames(ns, topicName string) ([]string, error)

PullSubscriptionNames returns a namespace topic's subscription names sorted.

func (*InMemoryBackend) PutDomain

func (b *InMemoryBackend) PutDomain(
	name, resourceID, inputSchema string, autoCreate, autoDelete *bool,
) (DomainInfo, error)

PutDomain creates a domain or updates its resource ID, input schema and topic management flags; a nil flag means true, the Event Grid default.

func (*InMemoryBackend) PutDomainTopic

func (b *InMemoryBackend) PutDomainTopic(domainName, name string) (time.Time, error)

PutDomainTopic creates a domain topic if absent.

func (*InMemoryBackend) PutNamespace

func (b *InMemoryBackend) PutNamespace(name string) error

PutNamespace creates an Event Grid namespace if absent.

func (*InMemoryBackend) PutNamespaceTopic

func (b *InMemoryBackend) PutNamespaceTopic(nsName, name string) (time.Time, error)

PutNamespaceTopic creates a namespace topic if absent.

func (*InMemoryBackend) PutPullSubscription

func (b *InMemoryBackend) PutPullSubscription(
	ns, topicName, name string,
	props map[string]any,
) (map[string]any, error)

PutPullSubscription creates or updates a namespace topic subscription.

func (*InMemoryBackend) PutScopedSubscription

func (b *InMemoryBackend) PutScopedSubscription(
	ctx context.Context, sc Scope, name string, props map[string]any,
) (map[string]any, error)

PutScopedSubscription creates or updates an event subscription on a custom topic, a domain or a domain topic. The first subscription of a missing domain topic creates it when the domain auto-creates topics.

func (*InMemoryBackend) PutSubscription

func (b *InMemoryBackend) PutSubscription(
	ctx context.Context, topicName, name string, props map[string]any,
) (map[string]any, error)

PutSubscription creates or updates an event subscription on a custom topic and returns its ARM properties. A WebHook endpoint is validated first.

func (*InMemoryBackend) PutTopic

func (b *InMemoryBackend) PutTopic(name, resourceID, inputSchema string) (TopicInfo, error)

PutTopic creates a custom topic or updates its resource ID and input schema.

func (*InMemoryBackend) PutTopicMapped

func (b *InMemoryBackend) PutTopicMapped(
	name, resourceID, inputSchema string, mapping map[string]any,
) (TopicInfo, error)

PutTopicMapped is PutTopic with the ARM inputSchemaMapping of a CustomEventSchema topic.

func (*InMemoryBackend) Receive

func (b *InMemoryBackend) Receive(
	ctx context.Context, ns, topicName, sub string, maxEvents int, wait time.Duration,
) ([]Received, error)

Receive locks up to maxEvents available events, waiting up to wait for the first one.

func (*InMemoryBackend) RegenerateDomainKey

func (b *InMemoryBackend) RegenerateDomainKey(name, keyName string) (Keys, error)

RegenerateDomainKey replaces "key1" or "key2" (case-insensitive) with a new random key.

func (*InMemoryBackend) RegenerateNamespaceKey

func (b *InMemoryBackend) RegenerateNamespaceKey(name, keyName string) (Keys, error)

RegenerateNamespaceKey replaces "key1" or "key2" with a new random key.

func (*InMemoryBackend) RegenerateTopicKey

func (b *InMemoryBackend) RegenerateTopicKey(name, keyName string) (Keys, error)

RegenerateTopicKey replaces "key1" or "key2" (case-insensitive) with a new random key.

func (*InMemoryBackend) Reject

func (b *InMemoryBackend) Reject(ns, topicName, sub string, tokens []string) ([]string, []LockFailure, error)

Reject removes (dead-letters) the locked events.

func (*InMemoryBackend) Release

func (b *InMemoryBackend) Release(
	ns, topicName, sub string, tokens []string, delay time.Duration,
) ([]string, []LockFailure, error)

Release unlocks the events, making them available again after delay.

func (*InMemoryBackend) RenewLock

func (b *InMemoryBackend) RenewLock(ns, topicName, sub string, tokens []string) ([]string, []LockFailure, error)

RenewLock extends the lock of the events by the subscription's lock duration.

func (*InMemoryBackend) Reset

func (b *InMemoryBackend) Reset()

Reset drops all state.

func (*InMemoryBackend) ResolveNamespace

func (b *InMemoryBackend) ResolveNamespace(
	hostLabel, topicName string,
	r *http.Request,
	validate bool,
) (string, error)

ResolveNamespace picks the namespace that holds topicName for a namespace data-plane request.

func (*InMemoryBackend) ResolvePublisher

func (b *InMemoryBackend) ResolvePublisher(hostLabel string, r *http.Request, validate bool) (Publisher, error)

ResolvePublisher picks the custom topic or domain a publish request is for.

func (*InMemoryBackend) ResolveTopic

func (b *InMemoryBackend) ResolveTopic(hostLabel string, r *http.Request, validate bool) (string, error)

ResolveTopic picks the custom topic a publish request is for.

func (*InMemoryBackend) Restore

func (b *InMemoryBackend) Restore(ctx context.Context, data []byte) error

Restore implements persistence.Persistable.

func (*InMemoryBackend) RunDue

func (b *InMemoryBackend) RunDue(ctx context.Context) int

RunDue attempts every delivery whose time has come and returns how many were attempted. Network calls run outside the backend lock.

func (*InMemoryBackend) ScopedFullURL

func (b *InMemoryBackend) ScopedFullURL(sc Scope, name string) (string, error)

ScopedFullURL returns the complete webhook endpoint URL of an event subscription.

func (*InMemoryBackend) ScopedSubscription

func (b *InMemoryBackend) ScopedSubscription(sc Scope, name string) (map[string]any, error)

ScopedSubscription returns the ARM properties of an event subscription.

func (*InMemoryBackend) ScopedSubscriptionNames

func (b *InMemoryBackend) ScopedSubscriptionNames(sc Scope) ([]string, error)

ScopedSubscriptionNames returns the event subscription names of a custom topic, domain, domain topic or resource scope, sorted.

func (*InMemoryBackend) SetTargets

func (b *InMemoryBackend) SetTargets(t Targets)

SetTargets wires the Service Bus, Event Hubs, Storage Queue and Blob sinks.

func (*InMemoryBackend) SetValidationBase

func (b *InMemoryBackend) SetValidationBase(base string)

SetValidationBase sets the base URL used in webhook validationUrl values.

func (*InMemoryBackend) Snapshot

func (b *InMemoryBackend) Snapshot(ctx context.Context) []byte

Snapshot implements persistence.Persistable.

func (*InMemoryBackend) Subscription

func (b *InMemoryBackend) Subscription(topicName, name string) (map[string]any, error)

Subscription returns the ARM properties of a custom topic's event subscription.

func (*InMemoryBackend) SubscriptionCreated

func (b *InMemoryBackend) SubscriptionCreated(topicName, name string) (time.Time, error)

SubscriptionCreated returns an event subscription's creation time.

func (*InMemoryBackend) SubscriptionNames

func (b *InMemoryBackend) SubscriptionNames(topicName string) ([]string, error)

SubscriptionNames returns a custom topic's event subscription names sorted.

func (*InMemoryBackend) Topic

func (b *InMemoryBackend) Topic(name string) (TopicInfo, error)

Topic returns the custom topic.

func (*InMemoryBackend) TopicKeys

func (b *InMemoryBackend) TopicKeys(name string) (Keys, error)

TopicKeys returns the topic's access keys.

func (*InMemoryBackend) TopicNames

func (b *InMemoryBackend) TopicNames() []string

TopicNames returns the custom topic names sorted.

type InputMapping

type InputMapping struct {
	ID          MappingField `json:"id"`
	Topic       MappingField `json:"topic"`
	EventTime   MappingField `json:"eventTime"`
	Subject     MappingField `json:"subject"`
	EventType   MappingField `json:"eventType"`
	DataVersion MappingField `json:"dataVersion"`
}

InputMapping is a custom topic's JSON input schema mapping.

func ParseInputMapping

func ParseInputMapping(raw map[string]any) (*InputMapping, error)

ParseInputMapping reads the ARM inputSchemaMapping object (JsonInputSchemaMapping); nil in, nil out.

type Keys

type Keys struct {
	Key1 string
	Key2 string
}

Keys is a primary/secondary access key pair.

type LockFailure

type LockFailure struct {
	LockToken string
	Code      string
	Message   string
}

LockFailure reports a lock token an operation could not apply to.

type MappingField

type MappingField struct {
	SourceField  string `json:"sourceField,omitempty"`
	DefaultValue string `json:"defaultValue,omitempty"`
}

MappingField maps one Event Grid event property from a field of the published event; DefaultValue is used when SourceField is unset or the event has no such property.

type Message

type Message struct {
	ID          string
	Subject     string
	ContentType string
	Body        []byte
}

Message is what a sink receives for one delivered event.

type Provider

type Provider struct{}

Provider implements service.Provider for Azure Event Grid.

func (*Provider) Init

Init builds the backend and handler; the port is bound by Handler.StartWorker.

func (*Provider) Name

func (p *Provider) Name() string

Name returns the service provider name.

type Publisher

type Publisher struct {
	Name   string
	Domain bool
}

Publisher is the custom topic or domain a publish request addresses.

type Received

type Received struct {
	LockToken     string
	Event         jsontext.Value
	DeliveryCount int
}

Received is one event handed out by a receive call.

type ResourceEvent

type ResourceEvent struct {
	Time            time.Time
	Claims          map[string]any
	EventType       string
	SubscriptionID  string
	ResourceGroup   string
	ResourceURI     string
	Provider        string
	OperationName   string
	CorrelationID   string
	TenantID        string
	HTTPMethod      string
	HTTPURL         string
	ClientRequestID string
	ClientIP        string
}

ResourceEvent describes a successful Azure Resource Manager write, delete or action.

type RetryPolicy

type RetryPolicy struct {
	MaxDeliveryAttempts      int `json:"maxDeliveryAttempts"`
	EventTimeToLiveInMinutes int `json:"eventTimeToLiveInMinutes"`
}

RetryPolicy bounds the delivery retries of an event subscription.

type Scope

type Scope struct {
	Domain   string
	Topic    string
	Resource string
}

Scope addresses the owner of event subscriptions: a custom topic (Topic only), a domain (Domain only), a domain topic (both) or an Azure Resource Manager scope such as a subscription, resource group or resource (Resource only).

type ScopeSubscriptions

type ScopeSubscriptions struct {
	ID            string
	Subscriptions []string
}

ScopeSubscriptions lists the event subscriptions owned by one Azure Resource Manager scope.

type Settings

type Settings struct {
	TLSCertFile string `` //nolint:lll // config struct tags are intentionally verbose
	/* 236-byte string literal not displayed */
	TLSKeyFile string `` //nolint:lll // config struct tags are intentionally verbose
	/* 138-byte string literal not displayed */
	Advertise string `` //nolint:lll // config struct tags are intentionally verbose
	/* 184-byte string literal not displayed */
	Port int `` //nolint:lll // config struct tags are intentionally verbose
	/* 252-byte string literal not displayed */
	ValidateSAS bool `` //nolint:lll // config struct tags are intentionally verbose
	/* 252-byte string literal not displayed */
}

Settings is the Kong-embedded configuration of the Event Grid emulator.

func DefaultSettings

func DefaultSettings() Settings

DefaultSettings returns the settings used when no ConfigProvider exists.

type Spec

type Spec struct {
	DeadLetterDestination *Destination `json:"deadLetterDestination,omitempty"`
	ExpirationTimeUTC     string       `json:"expirationTimeUtc,omitempty"`
	EventDeliverySchema   string       `json:"eventDeliverySchema,omitempty"`
	Destination           Destination  `json:"destination"`
	Labels                []string     `json:"labels,omitempty"`
	Filter                Filter       `json:"filter"`
	RetryPolicy           RetryPolicy  `json:"retryPolicy"`
}

Spec is the configurable part of an event subscription, in ARM property shape.

type StorageEvent

type StorageEvent struct {
	Time            time.Time
	Account         string
	Container       string
	Blob            string
	EventType       string
	API             string
	ContentType     string
	ETag            string
	AccessTier      string
	RequestID       string
	ClientRequestID string
	BlobURL         string
	ContentLength   int64
}

StorageEvent is a Blob Storage event (Learn: event-grid/event-schema-blob-storage).

type Targets

type Targets interface {
	SendServiceBus(queue, topic string, m Message) error
	SendEventHub(namespace, hub string, m Message) error
	SendStorageQueue(account, queue, text string, ttl time.Duration) error
	PutBlob(account, container, blob string, data []byte, contentType string) error
	InvokeFunction(ctx context.Context, app, function string, body []byte, contentType string) error
}

Targets are the in-emulator sinks an event subscription can deliver into. Implementations live in internal/app so this package imports no sibling service.

type TopicInfo

type TopicInfo struct {
	CreatedAt   time.Time
	Name        string
	ResourceID  string
	InputSchema string
}

TopicInfo is the exported view of a custom topic.

Jump to

Keyboard shortcuts

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