Categorygithub.com/streamdal/go-sdk
repositorypackage
0.0.86
Repository: https://github.com/streamdal/go-sdk.git
Documentation: pkg.go.dev

# Packages

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# README

Streamdal Go SDK

Master build status Test Coverage Maintainability Go Report Card GitHub

Documentation

See https://docs.streamdal.com

Installation

go get github.com/streamdal/go-sdk

Example Usage

package main

import (
	"context"
	"fmt"

	"github.com/streamdal/go-sdk"
)

func main() {
	sc, _ := streamdal.New(&streamdal.Config{
		// Address of the streamdal server
		ServerURL:       "streamdal-server.svc.cluster.local:8082",
		
		// Token used for authenticating with the streamdal server
		ServerToken:     "1234",
		
		// Identify _this_ application/service (
		ServiceName:     "billing-svc",
	})
	
	resp := sc.Process(context.Background(), &streamdal.ProcessRequest{
		OperationType: streamdal.OperationTypeConsumer,
		OperationName: "new-order-topic",
		ComponentName: "kafka",
		Data:          []byte(`{"object": {"field": true}}`),
	})
	
	// Check if the .Process() call completed
	if resp.Status != streamdal.StatusError {
		fmt.Println("Successfully processed payload")
    }
	
	// Or you can inspect each individual pipeline & step result
	for _, pipeline := resp.PipelineStatus {
		fmt.Printf("Inspecting '%d' steps in pipeline '%s'...\n", len(resp.PipelineStatus), pipeline.Name)
		
		for _, step := range pipeline.StepStatus {
			fmt.Printf("Step '%s' status: '%s'\n", step.Name, step.Status)
		}
    }
}

Configuration

All configuration can be passed via streamdal.Config{}. Some values can be set via environment variables in order to support 12-Factor and usage of this SDK inside shims where streamdal.Config{} cannot be set.

Config ParameterEnvironment VariableDescriptionDefault
ServerURLSTREAMDAL_URLURL pointing to your instance of streamdal server's gRPC API. Ex: localhost:8082empty
ServerTokenSTREAMDAL_TOKENAPI token set in streamdal serverempty
ServiceNameSTREAMDAL_SERVICE_NAMEIdentifies this service in the streamdal consoleempty
PipelineTimeoutSTREAMDAL_PIPELINE_TIMEOUTMaximum time a pipeline can run before giving up100ms
StepTimeoutSTREAMDAL_STEP_TIMEOUTMaximum time a pipeline step can run before giving up10ms
DryRunSTREAMDAL_DRY_RUNIf true, no data will be modifiedfalse
LoggerAn optional custom logger
ClientType1 = ClientTypeSDK, 2 = ClientTypeShimClientTypeSDK
ShutdownCtx-Your application's main context which will receive shutdown signals

Metrics

Metrics are published to Streamdal server and are available in Prometheus format at http://streamdal_server_url:8081/metrics

MetricDescriptionLabels
streamdal_counter_consume_bytesNumber of bytes consumed by the clientservice, component_name, operation_name, pipeline_id, pipeline_name
streamdal_counter_consume_errorsNumber of errors encountered while consuming payloadsservice, component_name, operation_name, pipeline_id, pipeline_name
streamdal_counter_consume_processedNumber of payloads processed by the clientservice, component_name, operation_name, pipeline_id, pipeline_name
streamdal_counter_produce_bytesNumber of bytes produced by the clientservice, component_name, operation_name, pipeline_id, pipeline_name
streamdal_counter_produce_errorsNumber of errors encountered while producing payloadsservice, component_name, operation_name, pipeline_id, pipeline_name
streamdal_counter_produce_processedNumber of payloads processed by the clientservice, component_name, operation_name, pipeline_id, pipeline_name
streamdal_counter_notifyNumber of notifications sent to the serverservice, component_name, operation_name, pipeline_id, pipeline_name