Documentation
¶
Index ¶
- Constants
- Variables
- func DeserializeConcExampleResult(w *WorkerResult) (result.ConcExample, error)
- type Adapter
- func (a *Adapter) DequeueQuery() (Query, error)
- func (a *Adapter) PublishQuery(query Query) (<-chan *WorkerResult, error)
- func (a *Adapter) PublishResult(channelName string, value *WorkerResult) error
- func (a *Adapter) SomeoneListens(query Query) (bool, error)
- func (a *Adapter) Subscribe() <-chan *redis.Message
- func (a *Adapter) TestConnection(timeout time.Duration, cancel chan bool) error
- type ConcExampleArgs
- type Conf
- type Query
- type WorkerResult
Constants ¶
const ( MsgNewQuery = "newQuery" MsgNewResult = "newResult" DefaultQueueKey = "mqueryQueue" DefaultResultChannelPrefix = "mqueryResults" DefaultQueryChannel = "mqueryQueries" DefaultResultExpiration = 10 * time.Minute DefaultQueryAnswerTimeout = 60 * time.Second )
Variables ¶
var (
ErrorEmptyQueue = errors.New("no queries in the queue")
)
Functions ¶
func DeserializeConcExampleResult ¶
func DeserializeConcExampleResult(w *WorkerResult) (result.ConcExample, error)
Types ¶
type Adapter ¶
type Adapter struct {
// contains filtered or unexported fields
}
Adapter provides functions for query producers and consumers using Redis database. It leverages Redis' PUBSUB functionality to notify about incoming data.
func NewAdapter ¶
NewAdapter is a recommended factory function for creating new `Adapter` instances
func (*Adapter) DequeueQuery ¶
DequeueQuery looks for a query queued for processing. In case nothing is found, ErrorEmptyQueue is returned as an error.
func (*Adapter) PublishQuery ¶
func (a *Adapter) PublishQuery(query Query) (<-chan *WorkerResult, error)
PublishQuery publishes a new query and returns a channel by which a respective result will be returned. In case the process fails during the calculation, a respective error is packed into the WorkerResult value. The error returned by this method means that the publishing itself failed.
func (*Adapter) PublishResult ¶
func (a *Adapter) PublishResult(channelName string, value *WorkerResult) error
PublishResult sends notification via Redis PUBSUB mechanism and also stores the result so a notified listener can retrieve it.
func (*Adapter) SomeoneListens ¶
SomeoneListens tests if there is a listener for a channel specified in the provided `query`. If false, then there is nobody interested in the query anymore.
type ConcExampleArgs ¶
type Conf ¶
type Conf struct { Host string `json:"host"` Port int `json:"port"` DB int `json:"db"` Password string `json:"password"` ChannelQuery string `json:"channelQuery"` ChannelResultPrefix string `json:"channelResultPrefix"` QueryAnswerTimeoutSecs int `json:"queryAnswerTimeoutSecs"` }
func (*Conf) ServerInfo ¶
type Query ¶
type Query struct { ResultType result.ResultType `json:"resultType"` Channel string `json:"channel"` Func string `json:"func"` Args json.RawMessage `json:"args"` }
func DecodeQuery ¶
type WorkerResult ¶
type WorkerResult struct { ID string `json:"id"` ResultType result.ResultType `json:"resultType"` Value json.RawMessage `json:"value"` }
func CreateWorkerResult ¶
func CreateWorkerResult(value result.SerializableResult) (*WorkerResult, error)
func (*WorkerResult) AttachValue ¶
func (wr *WorkerResult) AttachValue(value result.SerializableResult) error