Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

new beanq3.0.1 #13

Merged
merged 2 commits into from
Oct 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions .idea/.gitignore

This file was deleted.

39 changes: 18 additions & 21 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,27 +1,26 @@
module github.com/retail-ai-inc/beanqui

go 1.19
go 1.22.0

require (
github.com/golang-jwt/jwt/v5 v5.2.0
github.com/redis/go-redis/v9 v9.4.0
github.com/retail-ai-inc/beanq v1.0.1-0.20240924031600-54d498001f24
github.com/spf13/cast v1.6.0
github.com/spf13/viper v1.18.2
go.mongodb.org/mongo-driver v1.17.0
github.com/go-redis/redis/v8 v8.11.5
github.com/golang-jwt/jwt/v5 v5.2.1
github.com/retail-ai-inc/beanq/v3 v3.1.0
github.com/spf13/cast v1.7.0
github.com/spf13/viper v1.19.0
go.mongodb.org/mongo-driver v1.17.1
)

require (
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
github.com/fsnotify/fsnotify v1.7.0 // indirect
github.com/go-redis/redis/v8 v8.11.5 // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/hashicorp/errwrap v1.0.0 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/go-multierror v1.1.1 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/klauspost/compress v1.17.7 // indirect
github.com/klauspost/compress v1.17.11 // indirect
github.com/labstack/gommon v0.4.2 // indirect
github.com/magiconair/properties v1.8.7 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
Expand All @@ -30,11 +29,11 @@ require (
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/montanaflynn/stats v0.7.1 // indirect
github.com/panjf2000/ants/v2 v2.9.0 // indirect
github.com/pelletier/go-toml/v2 v2.1.1 // indirect
github.com/panjf2000/ants/v2 v2.10.0 // indirect
github.com/pelletier/go-toml/v2 v2.2.3 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/rs/xid v1.5.0 // indirect
github.com/sagikazarmark/locafero v0.4.0 // indirect
github.com/rs/xid v1.6.0 // indirect
github.com/sagikazarmark/locafero v0.6.0 // indirect
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
github.com/sourcegraph/conc v0.3.0 // indirect
github.com/spf13/afero v1.11.0 // indirect
Expand All @@ -48,14 +47,12 @@ require (
github.com/youmark/pkcs8 v0.0.0-20240726163527-a2c0da244d78 // indirect
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.27.0 // indirect
golang.org/x/crypto v0.26.0 // indirect
golang.org/x/exp v0.0.0-20240222234643-814bf88cf225 // indirect
golang.org/x/crypto v0.28.0 // indirect
golang.org/x/exp v0.0.0-20241009180824-f66d83c29e7c // indirect
golang.org/x/sync v0.8.0 // indirect
golang.org/x/sys v0.23.0 // indirect
golang.org/x/text v0.17.0 // indirect
golang.org/x/sys v0.26.0 // indirect
golang.org/x/text v0.19.0 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)

//replace github.com/retail-ai-inc/beanq v0.0.0-20230913002842-6af5b4637917 => /home/kll/projects/beanq
68 changes: 52 additions & 16 deletions go.sum

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion internal/mongox/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package mongox

import (
"context"
"github.com/retail-ai-inc/beanq"
"github.com/retail-ai-inc/beanq/v3"
"github.com/spf13/viper"
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/bson/primitive"
Expand Down
5 changes: 2 additions & 3 deletions internal/redisx/redis.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
package redisx

import (
"github.com/retail-ai-inc/beanq"
"github.com/go-redis/redis/v8"
"github.com/retail-ai-inc/beanq/v3"
"github.com/spf13/viper"
"log"
"strings"
"sync"

"github.com/redis/go-redis/v9"
)

var (
Expand Down
4 changes: 2 additions & 2 deletions internal/redisx/tool.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (
"strings"
"time"

"github.com/retail-ai-inc/beanq/helper/json"
"github.com/retail-ai-inc/beanq/helper/stringx"
"github.com/retail-ai-inc/beanq/v3/helper/json"
"github.com/retail-ai-inc/beanq/v3/helper/stringx"
"github.com/spf13/cast"
)

Expand Down
60 changes: 55 additions & 5 deletions internal/routers/event_log_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ package routers

import (
"encoding/json"
"github.com/retail-ai-inc/beanq/v3"
"github.com/retail-ai-inc/beanqui/internal/mongox"
"github.com/retail-ai-inc/beanqui/internal/redisx"
"github.com/retail-ai-inc/beanqui/internal/routers/errorx"
"github.com/retail-ai-inc/beanqui/internal/routers/response"
"github.com/spf13/cast"
Expand Down Expand Up @@ -164,16 +166,64 @@ func (t *EventLog) Retry(w http.ResponseWriter, r *http.Request) {
m := make(map[string]any)
id := r.FormValue("id")
m["uniqueId"] = id
ctx := r.Context()

payload := make(map[string]any)
if err := json.Unmarshal([]byte(r.FormValue("data")), &payload); err != nil {
data := make(map[string]any)
if err := json.Unmarshal([]byte(r.FormValue("data")), &data); err != nil {
res.Msg = err.Error()
res.Code = errorx.InternalServerErrorCode
_ = res.Json(w, http.StatusInternalServerError)
return
}
m["data"] = payload
res.Data = m
_ = res.Json(w, http.StatusOK)

moodType := ""
if v, ok := data["moodType"]; ok {
moodType = v.(string)
}
payload := ""
if v, ok := data["payload"]; ok {
payload = v.(string)
}
channel := ""
if v, ok := data["channel"]; ok {
channel = v.(string)
}
topic := ""
if v, ok := data["topic"]; ok {
topic = v.(string)
}

bq := beanq.New(&redisx.BqConfig)

if moodType == string(beanq.SEQUENTIAL) {
return
}
if moodType == string(beanq.DELAY) {
executeTime := ""
if v, ok := data["executeTime"]; ok {
executeTime = v.(string)
}
dup, err := time.ParseInLocation(time.RFC3339, executeTime, time.Local)
if err != nil {
res.Msg = err.Error()
res.Code = errorx.InternalServerErrorCode
_ = res.Json(w, http.StatusOK)
return
}
if err := bq.BQ().WithContext(ctx).PublishAtTime(channel, topic, []byte(payload), dup); err != nil {
res.Msg = err.Error()
res.Code = errorx.InternalServerErrorCode
_ = res.Json(w, http.StatusOK)
return
}
return
}
if err := bq.BQ().WithContext(ctx).Publish(channel, topic, []byte(payload)); err != nil {
res.Msg = err.Error()
res.Code = errorx.InternalServerErrorCode
_ = res.Json(w, http.StatusOK)
return
}

return
}
4 changes: 2 additions & 2 deletions internal/routers/log_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import (
"strings"
"time"

"github.com/retail-ai-inc/beanq"
"github.com/retail-ai-inc/beanq/helper/json"
"github.com/retail-ai-inc/beanq/v3"
"github.com/retail-ai-inc/beanq/v3/helper/json"
"github.com/retail-ai-inc/beanqui/internal/redisx"
"github.com/retail-ai-inc/beanqui/internal/routers/errorx"
"github.com/retail-ai-inc/beanqui/internal/routers/response"
Expand Down
2 changes: 1 addition & 1 deletion internal/routers/logs_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"net/http"
"strings"

"github.com/retail-ai-inc/beanq/helper/json"
"github.com/retail-ai-inc/beanq/v3/helper/json"
"github.com/retail-ai-inc/beanqui/internal/redisx"
"github.com/retail-ai-inc/beanqui/internal/routers/errorx"
"github.com/retail-ai-inc/beanqui/internal/routers/response"
Expand Down
2 changes: 1 addition & 1 deletion internal/routers/response/result.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"sync"
"time"

"github.com/retail-ai-inc/beanq/helper/json"
"github.com/retail-ai-inc/beanq/v3/helper/json"
"github.com/retail-ai-inc/beanqui/internal/routers/errorx"
"github.com/spf13/cast"
)
Expand Down
5 changes: 5 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package main

import (
"embed"
"github.com/retail-ai-inc/beanqui/internal/redisx"
. "github.com/retail-ai-inc/beanqui/internal/routers"
"github.com/spf13/viper"
"io/fs"
Expand All @@ -21,6 +22,10 @@ func init() {
if err := viper.ReadInConfig(); err != nil {
log.Fatalln(err)
}
//Initialize configuration information
if err := viper.Unmarshal(&redisx.BqConfig); err != nil {
log.Fatalf("viper unmarshal err:%+v \n", err)
}
}

//go:embed ui
Expand Down
3 changes: 2 additions & 1 deletion ui/src/pages/log/event.vue
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@
actions
</button>
<ul class="dropdown-menu">
<li v-if="item.status != 'success'"><a class="dropdown-item" href="javascript:;" @click="retryInfo(item)">Retry</a></li>
<!--v-if="item.status == 'failed'"-->
<li ><a class="dropdown-item" href="javascript:;" @click="retryInfo(item)">Retry</a></li>
<li><a class="dropdown-item" href="javascript:;" @click="deleteInfo(item)">Delete</a></li>
<li><a class="dropdown-item" href="javascript:;" @click="editModal(item)">Edit Payload</a></li>
</ul>
Expand Down