docs: add some comments

This commit is contained in:
Alexander Baryshnikov 2020-09-21 23:09:05 +08:00
parent ebe7b1fad5
commit 554083128b
2 changed files with 8 additions and 0 deletions

4
worker/doc.go Normal file
View File

@ -0,0 +1,4 @@
// Processing unit
//
// Worker manages requests, queuing and re-queuing.
package worker

View File

@ -122,12 +122,15 @@ func (mgr *Worker) init() error {
})
}
// Cleanup internal resource.
func (mgr *Worker) Close() {
if fn := mgr.cleanup; fn != nil {
fn()
}
}
// Enqueue request to storage, save meta-info to meta storage and push id into processing queue. Generated ID
// always unique and returns only in case of successful enqueue.
func (mgr *Worker) Enqueue(req *http.Request) (string, error) {
id, err := mgr.saveRequest(req)
if err != nil {
@ -138,6 +141,7 @@ func (mgr *Worker) Enqueue(req *http.Request) (string, error) {
return id, err
}
// Complete request manually.
func (mgr *Worker) Complete(requestID string) error {
err := mgr.meta.Complete(requestID)
if err != nil {