turnerlabs / kplclientgo

A go client library for kplserver

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

kplclientgo

A go client library for kplserver

If ErrPort is set, this library can be used to retrieve any message that kplserver may fail to send to kinesis. You can set a callback function ErrHandler that will be invoked for every message. See the example usage below on how to set these vaiables.

Usage

package main

import (
	"log"
	"github.com/turnerlabs/kplclientgo"
)

func main() {

	//create a client
	kpl := kplclientgo.NewKPLClient("127.0.0.1", "3000")

	// Optionally handle the failed messages
	kpl.ErrPort = "3000"
	kpl.ErrHost = "127.0.0.1"
	
	kpl.ErrHandler = func(data string) {
		log.Print("Could not send the message to kinesis", data)
	}

	//start it up
	err := kpl.Start()
	if err != nil {
		panic(err)
	}

	//send a record
	err = kpl.PutRecord("some data")
	if err != nil {
		panic(err)
	}
}

development

Requires:

  • Go 1.13
  • docker-compose

To run tests

AWS_PROFILE=my-profile KINESIS_STREAM=my-stream ERROR_SOCKET_PORT=3001 go test

About

A go client library for kplserver

License:Apache License 2.0


Languages

Language:Go 88.4%Language:Makefile 11.6%