http

package
v0.10.6 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2024 License: Apache-2.0 Imports: 20 Imported by: 0

README

Http

Compass is a search and discovery engine built for querying application deployments, datasets and meta resources. It can also optionally track data flow relationships between these resources and allow the user to view a representation of the data flow graph.

Usage

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

Config Defination

Key Value Example Description
url string https://compass.requestcatcher.com/v1beta2/asset/{{ .Type }}/{{ .Urn }} URL to the http server, contains all the info needed to make the request, like port and route, support go text/template (see the properties in v1beta2.Asset) required
method string POST the method string of by which the request is to be made, e.g. POST/PATCH/GET required
success_code integer 200 to identify the expected success code the http server returns, defult is 200 optional
headers map "Content-Type": "application/json" to add any header/headers that may be required for making the request optional
script Object see Script Script for building custom payload *optional

Script

Key Value Example Description
engine string tengo Script engine. Only "tengo" is supported currently required
source string see Usage. [Tengo][tengo] script used to map the request into custom payload to be sent to url. required
Script Globals
asset

The asset record emitted by the extractor and processors is made available in the script environment as asset. The field names will be as per the Asset proto definition.

sink(Payload)

Send http request to url with payload.

exit()

Terminates the script execution.

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