-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Kyle Jackson
committed
Aug 26, 2024
1 parent
ed7c0f1
commit 1846eb5
Showing
25 changed files
with
814 additions
and
71 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
FROM golang:1.22.5-alpine3.20 | ||
|
||
WORKDIR /go/src/worker | ||
|
||
COPY . /go/src/worker | ||
|
||
RUN go get ./... | ||
RUN go build ./cmd/worker | ||
|
||
ENTRYPOINT ["./worker"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
package main | ||
|
||
import ( | ||
"errors" | ||
"github.com/wizedkyle/artifactsmmo/v2/internal/artifacts" | ||
"github.com/wizedkyle/artifactsmmo/v2/internal/controllers" | ||
"github.com/wizedkyle/artifactsmmo/v2/internal/database" | ||
"github.com/wizedkyle/artifactsmmo/v2/internal/models" | ||
"github.com/wizedkyle/artifactsmmo/v2/internal/utils" | ||
"go.uber.org/zap" | ||
"time" | ||
) | ||
|
||
func main() { | ||
utils.LoggerInit() | ||
artifacts.Init() | ||
database.Init() | ||
for { | ||
tasks, err := database.Client.ListTasks("", *artifacts.Client.CharacterName, 1, models.TaskStatusPending) | ||
if errors.Is(err, utils.ErrTasksNotFound) { | ||
utils.Logger.Info("no crafting tasks found", zap.Error(err)) | ||
time.Sleep(10 * time.Second) | ||
continue | ||
} else if err != nil { | ||
utils.Logger.Error("failed to get tasks from database", zap.Error(err)) | ||
continue | ||
} | ||
for _, task := range *tasks { | ||
switch task.ActionCategory { | ||
case models.Combat: | ||
reason, err := controllers.CompleteCombatOrder(task) | ||
if err != nil { | ||
utils.Logger.Error("failed to complete combat order", zap.Error(err)) | ||
err = database.Client.UpdateTask(task.Id, reason, models.TaskStatusSuccess) | ||
if err != nil { | ||
utils.Logger.Error("failed to update task status", zap.Error(err)) | ||
continue | ||
} | ||
continue | ||
} | ||
err = database.Client.UpdateTask(task.Id, "", models.TaskStatusSuccess) | ||
if err != nil { | ||
utils.Logger.Error("failed to update task status", zap.Error(err)) | ||
continue | ||
} | ||
continue | ||
case models.Crafting: | ||
reason, err := controllers.CompleteCraftingOrder(task) | ||
if err != nil { | ||
utils.Logger.Error("failed to complete crafting order", zap.Error(err)) | ||
err = database.Client.UpdateTask(task.Id, reason, models.TaskStatusSuccess) | ||
if err != nil { | ||
utils.Logger.Error("failed to update task status", zap.Error(err)) | ||
continue | ||
} | ||
continue | ||
} | ||
err = database.Client.UpdateTask(task.Id, "", models.TaskStatusSuccess) | ||
if err != nil { | ||
utils.Logger.Error("failed to update task status", zap.Error(err)) | ||
continue | ||
} | ||
default: | ||
utils.Logger.Info("no valid task action", zap.String("action", task.Action)) | ||
err := database.Client.UpdateTask(task.Id, "no valid task action", models.TaskStatusError) | ||
if err != nil { | ||
utils.Logger.Error("failed to update task status", zap.Error(err)) | ||
continue | ||
} | ||
} | ||
} | ||
time.Sleep(10 * time.Second) | ||
} | ||
// list all pending tasks from the database with a type of crafting | ||
// if no results continue | ||
// if results get the first array record | ||
// for number of quantity do crafting task | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.