Documentation ¶
Overview ¶
Package transform provides functions for transforming messages.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Transformer ¶
type Transformer interface {
Transform(context.Context, *message.Message) ([]*message.Message, error)
}
Transformer is the interface implemented by all transforms and provides the ability to transform a message.
Example ¶
package main import ( "context" "fmt" "github.com/brexhq/substation/v2/config" "github.com/brexhq/substation/v2/message" "github.com/brexhq/substation/v2/transform" ) func main() { ctx := context.TODO() // Copies the value of key "a" into key "b". cfg := config.Config{ Type: "object_copy", Settings: map[string]interface{}{ "object": map[string]interface{}{ "source_key": "a", "target_key": "b", }, }, } tf, err := transform.New(ctx, cfg) if err != nil { // handle err panic(err) } // Transformer is applied to a message. msg := message.New().SetData([]byte(`{"a":1}`)) results, err := tf.Transform(ctx, msg) if err != nil { // handle err panic(err) } for _, c := range results { fmt.Println(string(c.Data())) } }
Output: {"a":1,"b":1}
Source Files ¶
- aggregate.go
- aggregate_from_array.go
- aggregate_from_string.go
- aggregate_to_array.go
- aggregate_to_string.go
- array_join.go
- array_zip.go
- enrich.go
- enrich_aws_dynamodb_query.go
- enrich_aws_lambda.go
- enrich_dns_domain_lookup.go
- enrich_dns_ip_lookup.go
- enrich_dns_txt_lookup.go
- enrich_http_get.go
- enrich_http_post.go
- enrich_kv_store_item_get.go
- enrich_kv_store_item_set.go
- enrich_kv_store_set_add.go
- format.go
- format_from_base64.go
- format_from_gzip.go
- format_from_pretty_print.go
- format_from_zip.go
- format_to_base64.go
- format_to_gzip.go
- hash.go
- hash_md5.go
- hash_sha256.go
- meta_err.go
- meta_for_each.go
- meta_kv_store_lock.go
- meta_metric_duration.go
- meta_retry.go
- meta_switch.go
- network.go
- network_domain_registered_domain.go
- network_domain_subdomain.go
- network_domain_top_level_domain.go
- number.go
- number_math_addition.go
- number_math_division.go
- number_math_multiplication.go
- number_math_subtraction.go
- number_maximum.go
- number_minimum.go
- object_copy.go
- object_delete.go
- object_insert.go
- object_jq.go
- object_to_boolean.go
- object_to_float.go
- object_to_integer.go
- object_to_string.go
- object_to_unsigned_integer.go
- send.go
- send_aws_data_firehose.go
- send_aws_dynamodb_put.go
- send_aws_eventbridge.go
- send_aws_kinesis_data_stream.go
- send_aws_lambda.go
- send_aws_s3.go
- send_aws_sns.go
- send_aws_sqs.go
- send_file.go
- send_http_post.go
- send_stdout.go
- string.go
- string_append.go
- string_capture.go
- string_replace.go
- string_split.go
- string_to_lower.go
- string_to_snake.go
- string_to_upper.go
- string_uuid.go
- test_message.go
- time.go
- time_from_string.go
- time_from_unix.go
- time_from_unix_milli.go
- time_now.go
- time_to_string.go
- time_to_unix.go
- time_to_unix_milli.go
- transform.go
- utility_control.go
- utility_delay.go
- utility_drop.go
- utility_err.go
- utility_metric_bytes.go
- utility_metric_count.go
- utility_metric_freshness.go
- utility_secret.go
Click to show internal directories.
Click to hide internal directories.