example

package
v0.98.0 Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2026 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Overview

Package example implements the example provider adapter for the example capability.

Package example implements the example provider adapter for the example capability.

Index

Constants

View Source
const (
	OpList   = "list"
	OpGet    = "get"
	OpCreate = "create"
	OpUpdate = "update"
	OpDelete = "delete"
	OpHealth = "health"
)

Operation name constants for the example capability.

Variables

This section is empty.

Functions

func NewPoller

func NewPoller() capability.PollingResource

NewPoller creates an ExamplePoller backed by a default adapter.

func Register

func Register(app string, svc Service) error

Register registers the example capability with hub and invoker registry. When svc is nil the provider is not configured and registration is skipped.

Types

type Adapter

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

Adapter implements example.Service using the example provider client.

func (*Adapter) CreateItem

func (a *Adapter) CreateItem(ctx context.Context, title string, _ types.KV) (*capability.Host, error)

func (*Adapter) DeleteItem

func (a *Adapter) DeleteItem(ctx context.Context, id string) error

func (*Adapter) GetItem

func (a *Adapter) GetItem(ctx context.Context, id string) (*capability.Host, error)

func (*Adapter) HealthCheck

func (a *Adapter) HealthCheck(ctx context.Context) (bool, error)

func (*Adapter) ListItems

func (*Adapter) ListRawEvents

func (a *Adapter) ListRawEvents(ctx context.Context, cursor string) ([]any, string, error)

func (*Adapter) UpdateItem

func (a *Adapter) UpdateItem(ctx context.Context, id string, data map[string]any) (*capability.Host, error)

type ExamplePoller

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

ExamplePoller implements capability.PollingResource for the example provider. It polls the example provider for new and updated items via the example Service.

func NewPollerWithService

func NewPollerWithService(svc Service) *ExamplePoller

NewPollerWithService creates an ExamplePoller with a specific service, useful for testing.

func (*ExamplePoller) ContentHash

func (*ExamplePoller) ContentHash(item any) string

ContentHash returns a SHA256 hash of the item for content-based change detection.

func (*ExamplePoller) CursorField

func (*ExamplePoller) CursorField() string

CursorField returns the field name used for cursor-based pagination.

func (*ExamplePoller) DefaultInterval

func (*ExamplePoller) DefaultInterval() time.Duration

DefaultInterval returns the recommended polling interval.

func (*ExamplePoller) DiffKey

func (*ExamplePoller) DiffKey(item any) string

DiffKey returns the unique identifier for an item, used for change detection.

func (*ExamplePoller) List

func (p *ExamplePoller) List(ctx context.Context, cursor string) (capability.PollResult, error)

List fetches a batch of items from the provider starting after the given cursor.

func (*ExamplePoller) ResourceName

func (*ExamplePoller) ResourceName() string

ResourceName returns the unique name for this polling resource.

type ExampleWebhook

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

ExampleWebhook implements capability.WebhookConverter for the example provider. It demonstrates signature verification and payload conversion patterns.

func NewExampleWebhook

func NewExampleWebhook() *ExampleWebhook

NewExampleWebhook creates an ExampleWebhook that reads the HMAC secret from the example provider config at verification time.

func (*ExampleWebhook) Convert

func (*ExampleWebhook) Convert(body []byte, _ map[string]string) ([]types.DataEvent, error)

Convert transforms the raw webhook body into one or more DataEvent records.

func (*ExampleWebhook) VerifySignature

func (w *ExampleWebhook) VerifySignature(headers map[string]string, body []byte) error

VerifySignature validates the HMAC-SHA256 signature from the X-Signature header. The secret is read from provider config at verification time via getSecret.

func (*ExampleWebhook) WebhookPath

func (*ExampleWebhook) WebhookPath() string

WebhookPath returns the URL path that receives webhook events from the example provider.

type ListQuery

type ListQuery = capability.ExampleListQuery

ListQuery wraps pagination for listing items.

type Service

type Service interface {
	GetItem(ctx context.Context, id string) (*capability.Host, error)
	ListItems(ctx context.Context, q *ListQuery) (*capability.ListResult[capability.Host], error)
	CreateItem(ctx context.Context, title string, tags types.KV) (*capability.Host, error)
	UpdateItem(ctx context.Context, id string, data map[string]any) (*capability.Host, error)
	DeleteItem(ctx context.Context, id string) error
	HealthCheck(ctx context.Context) (bool, error)
	ListRawEvents(ctx context.Context, cursor string) ([]any, string, error)
}

Service defines the example capability contract.

func New

func New() Service

New creates an Adapter using the default provider client (reads config from YAML).

func NewWithClient

func NewWithClient(c client) Service

NewWithClient creates an Adapter with a specific client, useful for testing.

Jump to

Keyboard shortcuts

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