queue

package
v1.0.9 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Check

type Check struct {
	ID    string
	State CheckState
}

Check defines the relevant informartion for the runtime that executes and monitors checks.

type CheckState

type CheckState struct {
	Status   string              `json:"status,omitempty"`
	Progress float32             `json:"progress,omitempty"`
	Report   vulcanreport.Report `json:"report,omitempty"`
	Error    string              `json:"error,omitempty"`
}

CheckState defines the fields of a check relevant during its execution.

type Message

type Message struct {
	ExternalID string    `json:"external_id"`
	Received   time.Time `json:"Received"`
	Payload    string    `json:"payload"`
}

type Queue

type Queue interface {
	Dequeue() (*Check, error)
	Enqueue(Check) error
}

type SimpleMQ

type SimpleMQ struct {
	Addr  string
	Path  string
	Queue []Message
	Srv   *http.Server

	sync.Mutex
	// contains filtered or unexported fields
}

SimpleMQ is a very simple queue.

func New

func New(addr, path string) *SimpleMQ

New creates a new simple queue service that will listen to the given address.

func (*SimpleMQ) Dequeue

func (s *SimpleMQ) Dequeue() Message

Dequeue dequeue an element from the given queue.

func (*SimpleMQ) Enqueue

func (s *SimpleMQ) Enqueue(m Message)

Enqueue enqueue a message to a queue.

func (*SimpleMQ) ListenAndServe

func (s *SimpleMQ) ListenAndServe() error

ListenAndServe starts de queue, it blocks the calling goroutine.

func (*SimpleMQ) Stop

func (s *SimpleMQ) Stop() error

Stop stops the underlaying http server.

type SimpleMQClientServer

type SimpleMQClientServer struct {
	Addr string
	// contains filtered or unexported fields
}

func NewSimpleMQClientServer

func NewSimpleMQClientServer() (SimpleMQClientServer, error)

func (SimpleMQClientServer) Dequeue

func (s SimpleMQClientServer) Dequeue() (*Check, error)

func (SimpleMQClientServer) Enqueue

func (s SimpleMQClientServer) Enqueue(c Check) error

func (SimpleMQClientServer) Start

func (s SimpleMQClientServer) Start() error

func (SimpleMQClientServer) Stop

func (s SimpleMQClientServer) Stop() error

func (SimpleMQClientServer) WaitStart

func (s SimpleMQClientServer) WaitStart(timeout time.Duration) error

Jump to

Keyboard shortcuts

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