firehose

package module
v0.0.0-...-68c2477 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2018 License: MIT Imports: 14 Imported by: 1

README

go-firehose - A Cloud Foundry Firehose Platform

Travis CI

Writing Firehose Nozzles for Cloud Foundry should be easier than it is. This framework aims to make that want a reality.

Usage is (by design) straightforward. Import the library, and then implement the firehose.MyNozzle interface, and then pass an instance of that object to firehose.Go

Here's a small example that just prints stuff to standard output:

package main

import (
  "fmt"

  "github.com/cloudfoundry/sonde-go/events"
  "github.com/jhunt/go-firehose"
)

type MyNozzle struct{}

func (MyNozzle) Configure(c firehose.Config) {
  fmt.Printf("Configure() was called!\n")
}

func (MyNozzle) Track(e *events.Envelope) {
  fmt.Printf("received a %s message from %s\n", e.GetEventType(), e.GetOrigin())
}

func (MyNozzle) Flush() error {
  fmt.Printf("Flush() was called!\n")
  return nil
}

func (MyNozzle) SlowConsumer() {
  fmt.Printf("we are not keeping up with the firehose!\n")
}

func main() {
  firehose.Go(MyNozzle{}, "/etc/firehose.yml")
}

(more examples can be found in the examples/ directory. They are all buildable Go applications).

Caveats

This library uses the Go standard log library for printing messages it thinks you need to see. If you don't like this approach, find a different library. Pull requests to add JSON logging to this library will be closed without further explanation.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Go

func Go(dest Destination, config string)

Types

type Config

type Config struct {
	UAA                  UAAConfig `yaml:"uaa"`
	Prefix               string    `yaml:"prefix"                 env:"NOZZLE_PREFIX"`
	Subscription         string    `yaml:"subscription"           env:"NOZZLE_SUBSCRIPTION"`
	TrafficControllerURL string    `yaml:"traffic_controller_url" env:"NOZZLE_TRAFFIC_CONTROLLER_URL"`
	FlushInterval        string    `yaml:"flush_interval"         env:"NOZZLE_FLUSH_INTERVAL"`
	HighWatermark        string    `yaml:"high_watermark"         env:"NOZZLE_HIGH_WATERMARK"`
	IdleTimeout          string    `yaml:"idle_timeout"           env:"NOZZLE_IDLE_TIMEOUT"`
	// contains filtered or unexported fields
}

func ReadConfig

func ReadConfig(file string) (*Config, error)

type Destination

type Destination interface {
	Configure(c Config)
	Track(e Event)
	Flush() error
	SlowConsumer()
}

type Event

type Event struct {
	*events.Envelope
}

func (Event) Type

func (e Event) Type() EventType

type EventType

type EventType int
var (
	UnknownEvent    EventType = 0
	HttpStartStop   EventType = 4
	LogMessage      EventType = 5
	ValueMetric     EventType = 6
	CounterEvent    EventType = 7
	ErrorEvent      EventType = 8
	ContainerMetric EventType = 9
)

type Firehose

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

func (*Firehose) AuthToken

func (f *Firehose) AuthToken() string

func (*Firehose) RefreshAuthToken

func (f *Firehose) RefreshAuthToken() (string, error)

func (*Firehose) Start

func (f *Firehose) Start() error

type UAAConfig

type UAAConfig struct {
	Disabled   bool   `yaml:"disabled"    env:"NOZZLE_UAA_DISABLED"`
	URL        string `yaml:"url"         env:"NOZZLE_UAA_URL"`
	Client     string `yaml:"client"      env:"NOZZLE_UAA_CLIENT"`
	Secret     string `yaml:"secret"      env:"NOZZLE_UAA_SECRET"`
	SkipVerify bool   `yaml:"skip_verify" env:"NOZZLE_UAA_SKIP_VERIFY"`
}

Directories

Path Synopsis
examples
debug command
dump command
simple command

Jump to

Keyboard shortcuts

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