webque

package module
v0.0.0-...-564054f Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2016 License: MIT Imports: 18 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

webque

Go HTTP Queue/Worker Experiment

What it can do

  • Publish events using curl
  • Subscribe events and execute jobs
  • Jobs access external service by HTTP
  • Jobs write data to DB
  • Retry jobs if they fail with exp backoff

Prep

-- for proxy service
CREATE USER webque_proxy;
CREATE DATABASE webque_proxy OWNER webque_proxy;

-- for backend service
CREATE USER webque_backend;
CREATE DATABASE webque_backend OWNER webque_backend;

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidPointer = errors.New("attempt to load into an invalid pointer")
)

package errors

Functions

func BackendRun

func BackendRun()

BackendRun runs backend server

func CompleteLoadRequest

func CompleteLoadRequest(ctx context.Context, w http.ResponseWriter, r *http.Request)

CompleteLoadRequest update completed status

func CreateLoadRequest

func CreateLoadRequest(ctx context.Context, w http.ResponseWriter, r *http.Request)

CreateLoadRequest add load request

func CreateLoadRequestService

func CreateLoadRequestService(tx *pgx.Tx, req LoadRequestRequest) error

CreateLoadRequestService creates load request

func CreateTransferRequest

func CreateTransferRequest(ctx context.Context, w http.ResponseWriter, r *http.Request)

CreateTransferRequest add transfer request

func GetCurrentDeposit

func GetCurrentDeposit(ctx context.Context, w http.ResponseWriter, r *http.Request)

GetCurrentDeposit get current deposit

func GetLoadRequest

func GetLoadRequest(ctx context.Context, w http.ResponseWriter, r *http.Request)

GetLoadRequest get load requests

func GetTransferRequest

func GetTransferRequest(ctx context.Context, w http.ResponseWriter, r *http.Request)

GetTransferRequest get transfer request

func HelloJob

func HelloJob(j *que.Job) error

HelloJob says hello

func Load

func Load(rows *pgx.Rows, value interface{}) (int, error)

Load loads any value from sql.Rows

func NewBackendDB

func NewBackendDB(dbURI string) (*pgx.ConnPool, error)

NewBackendDB create DB

func NewHTTPClient

func NewHTTPClient() *http.Client

NewHTTPClient creates http client

func NewProxyDB

func NewProxyDB(dbURI string) (*pgx.ConnPool, error)

NewProxyDB create DB

func NewQueClient

func NewQueClient(dbURI string) (*que.Client, error)

NewQueClient create que client

func NotFound

func NotFound(ctx context.Context, w http.ResponseWriter, r *http.Request)

NotFound returns not found message

func ProxyRun

func ProxyRun()

ProxyRun runs proxy service

func ToInsertSQL

func ToInsertSQL(stmt *dbr.InsertStmt) (string, error)

ToInsertSQL create insert sql string

func ToSelectSQL

func ToSelectSQL(stmt *dbr.SelectStmt) (string, error)

ToSelectSQL create select sql string

func ToUpdateSQL

func ToUpdateSQL(stmt *dbr.UpdateStmt) (string, error)

ToUpdateSQL create update sql string

func UpdateCurrentDeposit

func UpdateCurrentDeposit(ctx context.Context, w http.ResponseWriter, r *http.Request)

UpdateCurrentDeposit create/update current deposit

func UpdateDepositJob

func UpdateDepositJob(j *que.Job) error

UpdateDepositJob updates deposit in backend service

func UpdateLoadRequestService

func UpdateLoadRequestService(tx *pgx.Tx, req LoadRequestRequest) error

UpdateLoadRequestService updates load request

Types

type Account

type Account struct {
	ID   int    `json:"accountID"`
	Name string `json:"name"`
}

Account struct

type GetLoadRequestRequest

type GetLoadRequestRequest struct {
	AccountID int `json:"accountId"`
}

GetLoadRequestRequest load request

type LoadRequestModel

type LoadRequestModel struct {
	ID        int32     `json:"id"`
	AccountID int32     `json:"accountID"`
	Amount    int32     `json:"amount"`
	Completed bool      `json:"completed"`
	CreatedAt time.Time `json:"createdAt"`
	UpdatedAt time.Time `json:"updatedAt"`
}

LoadRequestModel load request struct

func GetLoadRequestService

func GetLoadRequestService(tx *pgx.Tx, req GetLoadRequestRequest) ([]LoadRequestModel, error)

GetLoadRequestService get load request

type LoadRequestRequest

type LoadRequestRequest struct {
	RequestID int `json:"id"`
	AccountID int `json:"accountId"`
	Amount    int `json:"amount"`
}

LoadRequestRequest load request struct

type LoadRequestResponse

type LoadRequestResponse struct {
	Data []LoadRequestModel `json:"data"`
}

LoadRequestResponse struct

type MessageResponse

type MessageResponse struct {
	Data StatusMessage `json:"data"`
}

MessageResponse struct

type StatusMessage

type StatusMessage struct {
	Message   string `json:"message"`
	RequestID int    `json:"requestId,omitempty"`
}

StatusMessage struct

type TransferRequestRequest

type TransferRequestRequest struct {
	FromAccountID int `json:"fromAccountId"`
	ToAccountID   int `json:"toAccountId"`
	Amount        int `json:"amount"`
}

TransferRequestRequest transfer request struct

Directories

Path Synopsis
cmd
webque-backend command
webque-proxy command

Jump to

Keyboard shortcuts

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