porter

package
v0.0.0-...-eb336c4 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2022 License: MPL-2.0 Imports: 30 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AllowCors

func AllowCors(next http.Handler) http.Handler

func Publisher

func Publisher(base *Base, queries <-chan QueryRequestWrap)

func Serve

func Serve(base *Base, s *bot.Sylon, queries chan<- QueryRequestWrap)

func SetQRespInCache

func SetQRespInCache(base *Base, requestId string, status QStatus, msg string)

Types

type Base

type Base struct {
	Config    *storage.InternalConfig
	MediaPath string
	R         *sqlx.DB
	Cache     caching.Cache
	Log       *zap.Logger
}

func InitBase

func InitBase(config *storage.InternalConfig, db *sqlx.DB, lg *zap.Logger) *Base

func (*Base) CreateMediaDirIfNotExists

func (b *Base) CreateMediaDirIfNotExists(dirname string) string

CreateMediaDirIfNotExists creates the directory in default media path. It can accept nested directory path, but all parent directories must exist. Returns full directory path.

func (*Base) ServeGRPC

func (b *Base) ServeGRPC(sylon *bot.Sylon)

type ProjectResp

type ProjectResp struct {
	ID          string         `db:"id"`
	SecretKey   string         `db:"secret_key"`
	PrettyTitle sql.NullString `db:"pretty_title"`
}

type PublicController

type PublicController struct {
	B *Base
}

type QResp

type QResp struct {
	Status QStatus                  `json:"status,omitempty"`
	Msg    string                   `json:"msg,omitempty"`
	Result []map[string]interface{} `json:"result,omitempty"`
}

type QStatus

type QStatus int
const (
	QWorking QStatus = iota
	QDone
	QFailed
)

type QueryRequest

type QueryRequest struct {
	RequestID string `json:"request_id,omitempty"`
	ProjectID string `json:"project_id,omitempty"`
	QueryText string `json:"query_text,omitempty"`
	Fields    string `json:"fields,omitempty"`
	Regex     string `json:"regex,omitempty"`
}

type QueryRequestWrap

type QueryRequestWrap struct {
	ProjectID string
	QID       string
	Json      []byte
}

Jump to

Keyboard shortcuts

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