Documentation
¶
Overview ¶
Package my contains the Request object
Index ¶
- Constants
- type Instance
- type Request
- func (rq *Request) AddDB(key string) bool
- func (rq *Request) AddDurationLog(start time.Time)
- func (rq *Request) AddErrorLog(err error)
- func (rq *Request) AddFmtLog(format string, args ...any)
- func (rq *Request) AddLog(message string)
- func (rq *Request) AddTxStep(q qb.Query)
- func (rq *Request) CommitTransaction() error
- func (rq *Request) Fail(status int, message string, args ...any)
- func (rq *Request) MergeLogs(srq *Request)
- func (rq *Request) Output() string
- func (rq *Request) SetNow() clock.DateTime
- func (rq *Request) StartTransaction(numSteps int) error
- func (rq *Request) SubRequest() *Request
- func (rq *Request) SwitchDB(key string) bool
- type Task
Constants ¶
const ( OK200 int = http.StatusOK // OK OK201 int = http.StatusCreated // Created Err400 int = http.StatusBadRequest // Client-Side Error Err401 int = http.StatusUnauthorized // Unauthenticated Err403 int = http.StatusForbidden // Unauthorized Err404 int = http.StatusNotFound // Not Found Err429 int = http.StatusTooManyRequests // Rate Limiting Err500 int = http.StatusInternalServerError // Server-Side Error )
const MainDB string = "main"
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Instance ¶
type Instance struct {
// contains filtered or unexported fields
}
Instance type stores the db connection pools for requests
func NewInstance ¶
func NewInstance(p *db.ConnParams) (*Instance, error)
NewInstance creates a new Instance object
func (*Instance) AddConnection ¶
func (i *Instance) AddConnection(name string, p *db.ConnParams) error
AddConnection adds a custom DB connection
func (*Instance) NewRequest ¶
NewRequest creates a new Request
type Request ¶
type Request struct {
Task
Name string
Params dict.Object
DB db.Conn
Tx db.Tx
Checker qb.ResultChecker
Status int
Now clock.DateTime
// contains filtered or unexported fields
}
Request is an application request that holds a DB connection, a transaction, result checker, transaction queries, request start time, and logs
func (*Request) AddDurationLog ¶
AddDurationLog adds a duration log message to the request
func (*Request) AddErrorLog ¶
AddErrorLog adds an error log message to the request
func (*Request) CommitTransaction ¶
CommitTransaction commits the database transaction
func (*Request) MergeLogs ¶
MergeLogs performs a concurrent-safe merging of subrequest logs to main request logs
func (*Request) StartTransaction ¶
StartTransaction starts a database transaction
func (*Request) SubRequest ¶
SubRequest creates a sub-request for concurrent tasks