http

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2026 License: Apache-2.0 Imports: 20 Imported by: 0

README

HTTP

Send metadata to any HTTP endpoint, with optional Tengo script transforms.

Usage

sinks:
  - name: http
    config:
      method: POST
      success_code: 200
      url: "https://example.com/v1/entity/{{ .Type }}/{{ .Urn }}"
      headers:
        Header-1: value11,value12
      script:
        engine: tengo
        source: |
          payload := {
            details: {
              some_key: entity.urn,
              another_key: entity.name
            }
          }
          sink(payload)

Configuration

Key Type Example Description
url string https://example.com/v1/entity/{{ .Type }}/{{ .Urn }} URL of the HTTP endpoint. Supports Go text/template with Entity fields: Urn, Type, Name, Source, Description. required
method string POST HTTP method (e.g. POST, PUT, PATCH) required
success_code int 200 Expected HTTP status code for success. Default: 200. optional
headers map Content-Type: application/json Additional HTTP headers. Multiple values are comma-separated. optional
script object see below Script for building a custom payload. optional
Script
Key Type Example Description
engine string tengo Script engine. Only tengo is supported. required
source string see Usage Tengo script that builds the request payload. required

Script globals:

  • entity -- The Entity object with fields: urn, type, name, description, source, properties, create_time, update_time.
  • sink(payload) -- Sends the HTTP request with the given payload.
  • exit() -- Terminates script execution.

Behavior

For each Record, the Entity is sent as a JSON payload to the configured URL. If a script is provided, the script builds a custom payload instead of using the default Entity JSON. Server errors (5xx) are returned as retryable errors.

Contributing

Refer to the contribution guidelines for information on contributing to this module.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(c httpClient, logger log.Logger) plugins.Syncer

Types

type Config

type Config struct {
	URL         string            `mapstructure:"url" validate:"required"`
	Headers     map[string]string `mapstructure:"headers"`
	Method      string            `mapstructure:"method" validate:"required"`
	SuccessCode int               `mapstructure:"success_code" default:"200"`
	Script      *struct {
		Engine string `mapstructure:"engine" validate:"required,oneof=tengo"`
		Source string `mapstructure:"source" validate:"required"`
	} `mapstructure:"script"`
}

type Sink

type Sink struct {
	plugins.BasePlugin
	// contains filtered or unexported fields
}

func (*Sink) Close

func (*Sink) Close() error

func (*Sink) Init

func (s *Sink) Init(ctx context.Context, config plugins.Config) error

func (*Sink) Sink

func (s *Sink) Sink(ctx context.Context, batch []models.Record) error

Jump to

Keyboard shortcuts

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