consumer

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Dec 29, 2020 License: Apache-2.0 Imports: 11 Imported by: 0

README

Rotation event web consumer

Introduction

This package defines a rotation event consumer that maps GET request into CLI command. It is intended as example how to consumer rotation event.

Configuration
  • port: endpoint port
  • streams: collection of data streams matched by URI
    • URI: matching URI
    • Name: shall command name
    • Args: shall command arguments slice

example:

port: 8083
streams:
  - URI: /log/datastream1
    Name: /bin/bash
    Args:
      - /opt/app/script/datastream1.sh
      - $DestPath
      - $DestName
      - $TimePath

  - URI: /log/datastream1
    Name: /bin/bash
    Args:
      - /opt/app/script/datastream1.sh
      - $DestPath
      - $DestName
      - $TimePath

where /opt/app/script/datastream1.sh

#!/bin/bash

location=$1
filename=$2
timepath=$3

if [ "$location" == "" ]; then
    echo "location was empty"
    exit 1
fi
echo "cp ${location} gs://my.bucket/data/logs/${timepath}/${filename}"

Building service

git clone https://github.com/viant/tapper.git
cd tapper/emitter/consumer/app
go build streamer.go

Documentation

Overview

Package consumer defines log rotation streamer CLI consumer

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Port    string
	Streams []*config.Command
}

Config represents streamer config

func NewConfigFromURL

func NewConfigFromURL(URL string) (*Config, error)

NewConfigFromURL creates a config from Format

func (Config) Validate

func (c Config) Validate() error

Validate checks if config is valid

type Request

type Request struct {
	URL    string
	Params map[string]string
}

Request represents consumer request

type Server

type Server struct {
	*http.Server
	// contains filtered or unexported fields
}

Server represents consumer server

func NewServer

func NewServer(port string, service *Service) *Server

NewServer creates a new service

func (*Server) ServeHTTP

func (s *Server) ServeHTTP(writer http.ResponseWriter, httpRequest *http.Request)

ServeHTTP servers HTTP

type Service

type Service struct {
	// contains filtered or unexported fields
}

Service represents simple rotation event consumer to handle rotated logs.

func New

func New(cfg *Config) (*Service, error)

New creates a new rotation consumer service

func (*Service) Consume

func (s *Service) Consume(request *Request) error

Consume consumes rotation event

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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