rdb

package
v0.1.9 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2024 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MsgNewQuery                = "newQuery"
	MsgNewResult               = "newResult"
	DefaultQueueKey            = "mqueryQueue"
	DefaultResultChannelPrefix = "mqueryResults"
	DefaultQueryChannel        = "mqueryQueries"
	DefaultResultExpiration    = 10 * time.Minute
	DefaultQueryAnswerTimeout  = 60 * time.Second
)

Variables

View Source
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

func NewAdapter(conf *Conf) *Adapter

NewAdapter is a recommended factory function for creating new `Adapter` instances

func (*Adapter) DequeueQuery

func (a *Adapter) DequeueQuery() (Query, error)

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

func (a *Adapter) SomeoneListens(query Query) (bool, error)

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.

func (*Adapter) Subscribe

func (a *Adapter) Subscribe() <-chan *redis.Message

Subscribe subscribes to query queue.

func (*Adapter) TestConnection

func (a *Adapter) TestConnection(timeout time.Duration, cancel chan bool) error

type ConcExampleArgs

type ConcExampleArgs struct {
	CorpusPath        string   `json:"corpusPath"`
	Query             string   `json:"query"`
	Attrs             []string `json:"attrs"`
	MaxItems          int      `json:"maxItems"`
	StartLine         int      `json:"startLine"`
	MaxContext        int      `json:"maxContext"`
	ViewContextStruct string   `json:"viewContextStruct"`
}

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

func (conf *Conf) ServerInfo() string

func (*Conf) Validate added in v0.1.8

func (conf *Conf) Validate() error

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

func DecodeQuery(q string) (Query, error)

func (Query) ToJSON

func (q Query) ToJSON() (string, error)

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

Jump to

Keyboard shortcuts

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