lib

package
v0.0.0-...-1cd5659 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2017 License: Apache-2.0 Imports: 13 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FastGet

func FastGet(c *http.Client, url string, structPointer interface{}) ([]byte, int, error)

FastGet is a wrapper for http.Get which returns only the important data from the request and makes sure everyting is closed properly.

func SafeResponseClose

func SafeResponseClose(r *http.Response)

Types

type CheckTask

type CheckTask struct {
	Error string
	Done  bool
}

json return of check request

type Config

type Config struct {
	Amqp         string
	QueueSuffix  string
	ConsumeQueue string
	ResultsQueue string
	FailedQueue  string

	LogFile   string
	LogLevel  string
	VerifySSL bool

	Services map[string][]string

	// stuff for feed
	FeedPrefetchCount int

	// stuff for check
	CheckPrefetchCount  int
	WaitBetweenRequests int

	// stuff for submit
	SubmitPrefetchCount int
}

type Ctx

type Ctx struct {
	Config *Config

	Debug   *log.Logger
	Info    *log.Logger
	Warning *log.Logger

	AmqpConn *amqp.Connection
	Client   *http.Client

	Failed *QueueHandler
}

general context struct

func (*Ctx) Consume

func (c *Ctx) Consume(queue string, prefetchCount int, fn func(msg amqp.Delivery)) error

Consume connects to a queue as a consumer, sets the QoS and relays all incoming messages to the supplied function.

func (*Ctx) Init

func (c *Ctx) Init(cPath string) error

Init prepares all fields of the given Ctx sturct and returns an error if something went wrong. By default you should panic if an error is returned.

func (*Ctx) NackOnError

func (c *Ctx) NackOnError(err error, desc string, msg *amqp.Delivery) bool

NackOnError accepts an error, error description, and amqp message. If the error is not nil a NACK is sent in reply to the msg. The msg will be redirected to the failed queue so the overseer, ehhm, "something" can handle it.

func (*Ctx) SetupQueue

func (c *Ctx) SetupQueue(queue string) (*QueueHandler, error)

SetupQueue creates a new channel on top of the established amqp connection and declares a persistent queue with the given name. It then returns a pointer to a QueueHandler.

type ExternalRequest

type ExternalRequest struct {
	PrimaryURI   string              `json:"primaryURI"`
	SecondaryURI string              `json:"secondaryURI"`
	Filename     string              `json:"filename"`
	Tasks        map[string][]string `json:"tasks"`
	Tags         []string            `json:"tags"`
	Comment      string              `json:"comment"`
	Download     bool                `json:"download"`
	Source       string              `json:"source"`
	Attempts     int                 `json:"attempts"`
}

request from the gateway to totem-dynamic

type FailedMsg

type FailedMsg struct {
	Queue string
	Error string
	Desc  string
	Msg   string
}

type InternalRequest

type InternalRequest struct {
	Service         string
	URL             string
	TaskID          string
	FilePath        string
	Started         time.Time
	OriginalRequest *ExternalRequest
}

request between feed/check/submit

type NewTask

type NewTask struct {
	Error  string
	TaskID string
}

json return of feed request

type QueueHandler

type QueueHandler struct {
	Queue   string
	Channel *amqp.Channel
	C       *Ctx
}

func (*QueueHandler) Send

func (q *QueueHandler) Send(msg []byte) error

Send is used to send a message to a amqp queue. Channel and queue name are taken from the QueueHandler struct.

type Service

type Service struct {
	Name   string
	URL    string
	Client *http.Client
}

func (*Service) CheckTask

func (s *Service) CheckTask(taskID string) (*CheckTask, error)

CheckTask gets the current status of a task from the service and return the result as a CheckTask struct.

func (*Service) NewTask

func (s *Service) NewTask(sample string) (*NewTask, error)

NewTask sends a new task to the service and returns the result as a NewTask struct.

func (*Service) Status

func (s *Service) Status() (*Status, error)

Status gets the current status of the service and returns it as a Status struct.

func (*Service) TaskResults

func (s *Service) TaskResults(taskID string) (*TaskResults, error)

TaskResults collects the results for a given task from the service and returns them as a TaskResults struct.

type Status

type Status struct {
	Degraded  bool
	Error     string
	FreeSlots int
}

json return of status request

type TaskResults

type TaskResults struct {
	Error   string
	Results interface{}
}

json return of results request

Jump to

Keyboard shortcuts

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