Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FastGet ¶
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 ¶
Types ¶
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 ¶
Consume connects to a queue as a consumer, sets the QoS and relays all incoming messages to the supplied function.
func (*Ctx) Init ¶
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 ¶
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 InternalRequest ¶
type InternalRequest struct {
Service string
URL string
TaskID string
FilePath string
Started time.Time
OriginalRequest *ExternalRequest
}
request between feed/check/submit
type QueueHandler ¶
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 ¶
func (*Service) CheckTask ¶
CheckTask gets the current status of a task from the service and return the result as a CheckTask struct.
func (*Service) NewTask ¶
NewTask sends a new task to the service and returns the result as a NewTask struct.
func (*Service) Status ¶
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 TaskResults ¶
type TaskResults struct {
Error string
Results interface{}
}
json return of results request