mirror of
https://github.com/Rain-kl/OpenFlare.git
synced 2026-10-11 09:46:37 +08:00
修改路径
This commit is contained in:
@@ -39,7 +39,7 @@
|
|||||||
以下是项目的顶层目录结构及其职责, 如果有新增目录或文件,请务必在此处同步更新:
|
以下是项目的顶层目录结构及其职责, 如果有新增目录或文件,请务必在此处同步更新:
|
||||||
|
|
||||||
```
|
```
|
||||||
wavelet/ # 项目根目录(模块名: github.com/linux-do/credit)
|
wavelet/ # 项目根目录(模块名: github.com/Rain-kl/Wavelet)
|
||||||
├── main.go # 程序入口,调用 internal/cmd
|
├── main.go # 程序入口,调用 internal/cmd
|
||||||
├── go.mod / go.sum # Go 模块依赖
|
├── go.mod / go.sum # Go 模块依赖
|
||||||
├── config.yaml # 运行时配置(不提交到 Git)
|
├── config.yaml # 运行时配置(不提交到 Git)
|
||||||
|
|||||||
@@ -39,7 +39,7 @@
|
|||||||
以下是项目的顶层目录结构及其职责, 如果有新增目录或文件,请务必在此处同步更新:
|
以下是项目的顶层目录结构及其职责, 如果有新增目录或文件,请务必在此处同步更新:
|
||||||
|
|
||||||
```
|
```
|
||||||
wavelet/ # 项目根目录(模块名: github.com/linux-do/credit)
|
wavelet/ # 项目根目录(模块名: github.com/Rain-kl/Wavelet)
|
||||||
├── main.go # 程序入口,调用 internal/cmd
|
├── main.go # 程序入口,调用 internal/cmd
|
||||||
├── go.mod / go.sum # Go 模块依赖
|
├── go.mod / go.sum # Go 模块依赖
|
||||||
├── config.yaml # 运行时配置(不提交到 Git)
|
├── config.yaml # 运行时配置(不提交到 Git)
|
||||||
|
|||||||
@@ -88,7 +88,7 @@ The project was designed from the ground up to be **framework-first and business
|
|||||||
### 1. Clone the Repository
|
### 1. Clone the Repository
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
git clone https://github.com/linux-do/credit.git refreshing
|
git clone https://github.com/Rain-kl/Wavelet.git refreshing
|
||||||
cd refreshing
|
cd refreshing
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -88,7 +88,7 @@
|
|||||||
### 1. 克隆仓库
|
### 1. 克隆仓库
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
git clone https://github.com/linux-do/credit.git refreshing
|
git clone https://github.com/Rain-kl/Wavelet.git refreshing
|
||||||
cd refreshing
|
cd refreshing
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
@@ -2,11 +2,11 @@
|
|||||||
|
|
||||||
import * as React from "react"
|
import * as React from "react"
|
||||||
import Link from "next/link"
|
import Link from "next/link"
|
||||||
import { ArrowLeft, Calendar, Check, Copy, FileText } from "lucide-react"
|
import {ArrowLeft, Calendar, Check, Copy, FileText} from "lucide-react"
|
||||||
import { Button } from "@/components/ui/button"
|
import {Button} from "@/components/ui/button"
|
||||||
import { cn } from "@/lib/utils"
|
import {cn} from "@/lib/utils"
|
||||||
import { motion, useScroll, useSpring } from "motion/react"
|
import {motion, useScroll, useSpring} from "motion/react"
|
||||||
import type { PolicySection } from "./types"
|
import type {PolicySection} from "./types"
|
||||||
|
|
||||||
interface LegalPageLayoutProps {
|
interface LegalPageLayoutProps {
|
||||||
title: string
|
title: string
|
||||||
@@ -395,7 +395,7 @@ export function LegalPageLayout({
|
|||||||
对这些内容有疑问?
|
对这些内容有疑问?
|
||||||
</p>
|
</p>
|
||||||
<div className="flex justify-center gap-4">
|
<div className="flex justify-center gap-4">
|
||||||
<Link href="https://github.com/linux-do/credit/issues" target="_blank">
|
<Link href="https://github.com/Rain-kl/Wavelet/issues" target="_blank">
|
||||||
<Button variant="outline" className="h-9 text-xs">
|
<Button variant="outline" className="h-9 text-xs">
|
||||||
联系支持
|
联系支持
|
||||||
</Button>
|
</Button>
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ export const FooterSection = React.memo(function FooterSection({ className }: Fo
|
|||||||
通用的、现代化的后台管理系统脚手架。基于 Go + React 构建,开箱即用、完整基建、极易扩展。
|
通用的、现代化的后台管理系统脚手架。基于 Go + React 构建,开箱即用、完整基建、极易扩展。
|
||||||
</p>
|
</p>
|
||||||
<div className="flex gap-4 pt-2">
|
<div className="flex gap-4 pt-2">
|
||||||
<SocialLink icon={Github} href="https://github.com/linux-do/credit/" />
|
<SocialLink icon={Github} href="https://github.com/Rain-kl/Wavelet/" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -45,15 +45,15 @@ export const FooterSection = React.memo(function FooterSection({ className }: Fo
|
|||||||
<ul className="space-y-4 text-sm text-muted-foreground">
|
<ul className="space-y-4 text-sm text-muted-foreground">
|
||||||
<li><FooterLink href="/docs/how-to-use">快速开始</FooterLink></li>
|
<li><FooterLink href="/docs/how-to-use">快速开始</FooterLink></li>
|
||||||
<li><FooterLink href="/docs/api">API 文档</FooterLink></li>
|
<li><FooterLink href="/docs/api">API 文档</FooterLink></li>
|
||||||
<li><FooterLink href="https://github.com/linux-do/credit">源代码</FooterLink></li>
|
<li><FooterLink href="https://github.com/Rain-kl/Wavelet">源代码</FooterLink></li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="lg:col-span-1">
|
<div className="lg:col-span-1">
|
||||||
<h3 className="font-semibold text-foreground mb-6">社区</h3>
|
<h3 className="font-semibold text-foreground mb-6">社区</h3>
|
||||||
<ul className="space-y-4 text-sm text-muted-foreground">
|
<ul className="space-y-4 text-sm text-muted-foreground">
|
||||||
<li><FooterLink href="https://github.com/linux-do/credit/issues">GitHub Issues</FooterLink></li>
|
<li><FooterLink href="https://github.com/Rain-kl/Wavelet/issues">GitHub Issues</FooterLink></li>
|
||||||
<li><FooterLink href="https://github.com/linux-do/credit/discussions">讨论</FooterLink></li>
|
<li><FooterLink href="https://github.com/Rain-kl/Wavelet/discussions">讨论</FooterLink></li>
|
||||||
<li><FooterLink href="https://linux.do/">LINUX DO</FooterLink></li>
|
<li><FooterLink href="https://linux.do/">LINUX DO</FooterLink></li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
"use client"
|
"use client"
|
||||||
|
|
||||||
import { useEffect, useState, useCallback } from "react"
|
import {useCallback, useEffect, useState} from "react"
|
||||||
import { useRouter } from "next/navigation"
|
import {useRouter} from "next/navigation"
|
||||||
import {
|
import {
|
||||||
CommandDialog,
|
CommandDialog,
|
||||||
CommandEmpty,
|
CommandEmpty,
|
||||||
@@ -10,10 +10,10 @@ import {
|
|||||||
CommandItem,
|
CommandItem,
|
||||||
CommandList,
|
CommandList,
|
||||||
} from "@/components/ui/command"
|
} from "@/components/ui/command"
|
||||||
import { Kbd, KbdGroup } from "@/components/ui/kbd"
|
import {Kbd, KbdGroup} from "@/components/ui/kbd"
|
||||||
import { searchItems, type SearchItem } from "@/lib/utils/search-data"
|
import {type SearchItem, searchItems} from "@/lib/utils/search-data"
|
||||||
import { Home, Settings, FileText, Shield } from "lucide-react"
|
import {FileText, Home, Settings, Shield} from "lucide-react"
|
||||||
import { useUser } from "@/contexts/user-context"
|
import {useUser} from "@/contexts/user-context"
|
||||||
|
|
||||||
interface SearchDialogProps {
|
interface SearchDialogProps {
|
||||||
open: boolean
|
open: boolean
|
||||||
@@ -91,7 +91,7 @@ const getTips = (metaKey: string) => [
|
|||||||
<>
|
<>
|
||||||
<span className="text-muted-foreground/80 lowercase">遇到问题?欢迎提交</span>
|
<span className="text-muted-foreground/80 lowercase">遇到问题?欢迎提交</span>
|
||||||
<a
|
<a
|
||||||
href="https://github.com/linux-do/credit/issues"
|
href="https://github.com/Rain-kl/Wavelet/issues"
|
||||||
target="_blank"
|
target="_blank"
|
||||||
rel="noopener noreferrer"
|
rel="noopener noreferrer"
|
||||||
className="text-primary hover:underline mx-1"
|
className="text-primary hover:underline mx-1"
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
module github.com/linux-do/credit
|
module github.com/Rain-kl/Wavelet
|
||||||
|
|
||||||
go 1.25.5
|
go 1.25.5
|
||||||
|
|
||||||
|
|||||||
@@ -5,9 +5,9 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
|
"github.com/Rain-kl/Wavelet/internal/model"
|
||||||
|
"github.com/Rain-kl/Wavelet/internal/util"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"github.com/linux-do/credit/internal/model"
|
|
||||||
"github.com/linux-do/credit/internal/util"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type AuthSourceRequest struct {
|
type AuthSourceRequest struct {
|
||||||
|
|||||||
@@ -23,11 +23,11 @@ import (
|
|||||||
"net/http/httptest"
|
"net/http/httptest"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/Rain-kl/Wavelet/internal/apps/oauth"
|
||||||
|
"github.com/Rain-kl/Wavelet/internal/model"
|
||||||
|
"github.com/Rain-kl/Wavelet/internal/testhelper"
|
||||||
|
"github.com/Rain-kl/Wavelet/internal/util"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"github.com/linux-do/credit/internal/apps/oauth"
|
|
||||||
"github.com/linux-do/credit/internal/model"
|
|
||||||
"github.com/linux-do/credit/internal/testhelper"
|
|
||||||
"github.com/linux-do/credit/internal/util"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func setupTestRouter(authUser *model.User) *gin.Engine {
|
func setupTestRouter(authUser *model.User) *gin.Engine {
|
||||||
|
|||||||
@@ -20,9 +20,9 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
|
"github.com/Rain-kl/Wavelet/internal/logger"
|
||||||
|
"github.com/Rain-kl/Wavelet/internal/util"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"github.com/linux-do/credit/internal/logger"
|
|
||||||
"github.com/linux-do/credit/internal/util"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const defaultLimit = 200
|
const defaultLimit = 200
|
||||||
|
|||||||
@@ -19,13 +19,13 @@ package admin
|
|||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"github.com/linux-do/credit/internal/logger"
|
"github.com/Rain-kl/Wavelet/internal/logger"
|
||||||
"github.com/linux-do/credit/internal/model"
|
"github.com/Rain-kl/Wavelet/internal/model"
|
||||||
"github.com/linux-do/credit/internal/otel_trace"
|
"github.com/Rain-kl/Wavelet/internal/otel_trace"
|
||||||
"github.com/linux-do/credit/internal/util"
|
"github.com/Rain-kl/Wavelet/internal/util"
|
||||||
|
|
||||||
|
"github.com/Rain-kl/Wavelet/internal/apps/oauth"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"github.com/linux-do/credit/internal/apps/oauth"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func LoginAdminRequired() gin.HandlerFunc {
|
func LoginAdminRequired() gin.HandlerFunc {
|
||||||
|
|||||||
@@ -23,8 +23,8 @@ import (
|
|||||||
"runtime"
|
"runtime"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/Rain-kl/Wavelet/internal/util"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"github.com/linux-do/credit/internal/util"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// startTime 记录服务启动时间
|
// startTime 记录服务启动时间
|
||||||
|
|||||||
@@ -20,11 +20,11 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
|
"github.com/Rain-kl/Wavelet/internal/db"
|
||||||
|
"github.com/Rain-kl/Wavelet/internal/model"
|
||||||
|
"github.com/Rain-kl/Wavelet/internal/util"
|
||||||
|
mail "github.com/Rain-kl/Wavelet/internal/util/mail"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"github.com/linux-do/credit/internal/db"
|
|
||||||
"github.com/linux-do/credit/internal/model"
|
|
||||||
"github.com/linux-do/credit/internal/util"
|
|
||||||
mail "github.com/linux-do/credit/internal/util/mail"
|
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -27,12 +27,12 @@ import (
|
|||||||
"net/textproto"
|
"net/textproto"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/Rain-kl/Wavelet/internal/apps/oauth"
|
||||||
|
"github.com/Rain-kl/Wavelet/internal/db"
|
||||||
|
"github.com/Rain-kl/Wavelet/internal/model"
|
||||||
|
"github.com/Rain-kl/Wavelet/internal/testhelper"
|
||||||
|
"github.com/Rain-kl/Wavelet/internal/util"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"github.com/linux-do/credit/internal/apps/oauth"
|
|
||||||
"github.com/linux-do/credit/internal/db"
|
|
||||||
"github.com/linux-do/credit/internal/model"
|
|
||||||
"github.com/linux-do/credit/internal/testhelper"
|
|
||||||
"github.com/linux-do/credit/internal/util"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func setupTestRouter(authUser *model.User) *gin.Engine {
|
func setupTestRouter(authUser *model.User) *gin.Engine {
|
||||||
|
|||||||
@@ -23,12 +23,17 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/Rain-kl/Wavelet/internal/model"
|
||||||
|
"github.com/Rain-kl/Wavelet/internal/task"
|
||||||
|
taskhandlers "github.com/Rain-kl/Wavelet/internal/task/handlers"
|
||||||
|
"github.com/Rain-kl/Wavelet/internal/util"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"github.com/linux-do/credit/internal/model"
|
|
||||||
"github.com/linux-do/credit/internal/task"
|
|
||||||
"github.com/linux-do/credit/internal/util"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
taskhandlers.Register()
|
||||||
|
}
|
||||||
|
|
||||||
// ListTaskTypes 获取支持的任务类型列表
|
// ListTaskTypes 获取支持的任务类型列表
|
||||||
// @Summary 获取支持的任务类型
|
// @Summary 获取支持的任务类型
|
||||||
// @Description 返回系统支持的所有可调度任务类型列表,包括任务名称、描述、是否支持时间范围等元数据,需要管理员权限
|
// @Description 返回系统支持的所有可调度任务类型列表,包括任务名称、描述、是否支持时间范围等元数据,需要管理员权限
|
||||||
|
|||||||
@@ -26,16 +26,31 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/Rain-kl/Wavelet/internal/apps/oauth"
|
||||||
|
"github.com/Rain-kl/Wavelet/internal/model"
|
||||||
|
"github.com/Rain-kl/Wavelet/internal/task"
|
||||||
|
"github.com/Rain-kl/Wavelet/internal/testhelper"
|
||||||
|
"github.com/Rain-kl/Wavelet/internal/util"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"github.com/linux-do/credit/internal/apps/oauth"
|
"github.com/hibiken/asynq"
|
||||||
"github.com/linux-do/credit/internal/model"
|
|
||||||
"github.com/linux-do/credit/internal/task"
|
|
||||||
"github.com/linux-do/credit/internal/testhelper"
|
|
||||||
"github.com/linux-do/credit/internal/util"
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func setupTaskTestEnvironment(t *testing.T) func() {
|
||||||
|
_, mr, cleanup := testhelper.SetupTestEnvironment(t)
|
||||||
|
task.AsynqClient = asynq.NewClient(asynq.RedisClientOpt{
|
||||||
|
Addr: mr.Addr(),
|
||||||
|
})
|
||||||
|
return func() {
|
||||||
|
if task.AsynqClient != nil {
|
||||||
|
task.AsynqClient.Close()
|
||||||
|
task.AsynqClient = nil
|
||||||
|
}
|
||||||
|
cleanup()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func setupTestRouter(authUser *model.User) *gin.Engine {
|
func setupTestRouter(authUser *model.User) *gin.Engine {
|
||||||
gin.SetMode(gin.TestMode)
|
gin.SetMode(gin.TestMode)
|
||||||
r := gin.New()
|
r := gin.New()
|
||||||
@@ -58,7 +73,7 @@ func setupTestRouter(authUser *model.User) *gin.Engine {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestListTaskTypes(t *testing.T) {
|
func TestListTaskTypes(t *testing.T) {
|
||||||
_, _, cleanup := testhelper.SetupTestEnvironment(t)
|
cleanup := setupTaskTestEnvironment(t)
|
||||||
defer cleanup()
|
defer cleanup()
|
||||||
|
|
||||||
adminUser := &model.User{ID: 1001, Username: "admin", IsAdmin: true}
|
adminUser := &model.User{ID: 1001, Username: "admin", IsAdmin: true}
|
||||||
@@ -96,7 +111,7 @@ func TestListTaskTypes(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestDispatchTask(t *testing.T) {
|
func TestDispatchTask(t *testing.T) {
|
||||||
_, _, cleanup := testhelper.SetupTestEnvironment(t)
|
cleanup := setupTaskTestEnvironment(t)
|
||||||
defer cleanup()
|
defer cleanup()
|
||||||
|
|
||||||
adminUser := &model.User{ID: 1001, Username: "admin", IsAdmin: true}
|
adminUser := &model.User{ID: 1001, Username: "admin", IsAdmin: true}
|
||||||
@@ -206,7 +221,7 @@ func TestDispatchTask(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestListTaskExecutions(t *testing.T) {
|
func TestListTaskExecutions(t *testing.T) {
|
||||||
_, _, cleanup := testhelper.SetupTestEnvironment(t)
|
cleanup := setupTaskTestEnvironment(t)
|
||||||
defer cleanup()
|
defer cleanup()
|
||||||
|
|
||||||
adminUser := &model.User{ID: 1001, Username: "admin", IsAdmin: true}
|
adminUser := &model.User{ID: 1001, Username: "admin", IsAdmin: true}
|
||||||
@@ -295,7 +310,7 @@ func TestListTaskExecutions(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestGetTaskExecution(t *testing.T) {
|
func TestGetTaskExecution(t *testing.T) {
|
||||||
_, _, cleanup := testhelper.SetupTestEnvironment(t)
|
cleanup := setupTaskTestEnvironment(t)
|
||||||
defer cleanup()
|
defer cleanup()
|
||||||
|
|
||||||
adminUser := &model.User{ID: 1001, Username: "admin", IsAdmin: true}
|
adminUser := &model.User{ID: 1001, Username: "admin", IsAdmin: true}
|
||||||
@@ -358,7 +373,7 @@ func TestGetTaskExecution(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestRetryTask(t *testing.T) {
|
func TestRetryTask(t *testing.T) {
|
||||||
_, _, cleanup := testhelper.SetupTestEnvironment(t)
|
cleanup := setupTaskTestEnvironment(t)
|
||||||
defer cleanup()
|
defer cleanup()
|
||||||
|
|
||||||
adminUser := &model.User{ID: 1001, Username: "admin", IsAdmin: true}
|
adminUser := &model.User{ID: 1001, Username: "admin", IsAdmin: true}
|
||||||
@@ -465,7 +480,7 @@ func TestRetryTask(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestRetryTaskMaxRetryExceeded(t *testing.T) {
|
func TestRetryTaskMaxRetryExceeded(t *testing.T) {
|
||||||
_, _, cleanup := testhelper.SetupTestEnvironment(t)
|
cleanup := setupTaskTestEnvironment(t)
|
||||||
defer cleanup()
|
defer cleanup()
|
||||||
|
|
||||||
adminUser := &model.User{ID: 1001, Username: "admin", IsAdmin: true}
|
adminUser := &model.User{ID: 1001, Username: "admin", IsAdmin: true}
|
||||||
|
|||||||
@@ -21,11 +21,11 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/Rain-kl/Wavelet/internal/db"
|
||||||
|
"github.com/Rain-kl/Wavelet/internal/db/idgen"
|
||||||
|
"github.com/Rain-kl/Wavelet/internal/model"
|
||||||
|
"github.com/Rain-kl/Wavelet/internal/util"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"github.com/linux-do/credit/internal/db"
|
|
||||||
"github.com/linux-do/credit/internal/db/idgen"
|
|
||||||
"github.com/linux-do/credit/internal/model"
|
|
||||||
"github.com/linux-do/credit/internal/util"
|
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -24,11 +24,11 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/Rain-kl/Wavelet/internal/apps/oauth"
|
||||||
|
"github.com/Rain-kl/Wavelet/internal/model"
|
||||||
|
"github.com/Rain-kl/Wavelet/internal/testhelper"
|
||||||
|
"github.com/Rain-kl/Wavelet/internal/util"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"github.com/linux-do/credit/internal/apps/oauth"
|
|
||||||
"github.com/linux-do/credit/internal/model"
|
|
||||||
"github.com/linux-do/credit/internal/testhelper"
|
|
||||||
"github.com/linux-do/credit/internal/util"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func setupTestRouter(authUser *model.User) *gin.Engine {
|
func setupTestRouter(authUser *model.User) *gin.Engine {
|
||||||
|
|||||||
@@ -3,9 +3,9 @@ package cap
|
|||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
|
"github.com/Rain-kl/Wavelet/internal/util"
|
||||||
|
caputil "github.com/Rain-kl/Wavelet/internal/util/cap"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"github.com/linux-do/credit/internal/util"
|
|
||||||
caputil "github.com/linux-do/credit/internal/util/cap"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// VerifyMiddleware returns a Gin middleware that checks and consumes the X-Cap-Token header.
|
// VerifyMiddleware returns a Gin middleware that checks and consumes the X-Cap-Token header.
|
||||||
|
|||||||
@@ -3,8 +3,8 @@ package cap
|
|||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
|
"github.com/Rain-kl/Wavelet/internal/util/cap"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"github.com/linux-do/credit/internal/util/cap"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type challengeRequest struct {
|
type challengeRequest struct {
|
||||||
|
|||||||
@@ -8,12 +8,12 @@ import (
|
|||||||
"net/http/httptest"
|
"net/http/httptest"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/Rain-kl/Wavelet/internal/db"
|
||||||
|
"github.com/Rain-kl/Wavelet/internal/model"
|
||||||
|
"github.com/Rain-kl/Wavelet/internal/testhelper"
|
||||||
|
"github.com/Rain-kl/Wavelet/internal/util"
|
||||||
|
capUtil "github.com/Rain-kl/Wavelet/internal/util/cap"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"github.com/linux-do/credit/internal/db"
|
|
||||||
"github.com/linux-do/credit/internal/model"
|
|
||||||
"github.com/linux-do/credit/internal/testhelper"
|
|
||||||
"github.com/linux-do/credit/internal/util"
|
|
||||||
capUtil "github.com/linux-do/credit/internal/util/cap"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestCapEndpointsAndMiddleware(t *testing.T) {
|
func TestCapEndpointsAndMiddleware(t *testing.T) {
|
||||||
|
|||||||
@@ -19,9 +19,9 @@ package config
|
|||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
|
"github.com/Rain-kl/Wavelet/internal/model"
|
||||||
|
"github.com/Rain-kl/Wavelet/internal/util"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"github.com/linux-do/credit/internal/model"
|
|
||||||
"github.com/linux-do/credit/internal/util"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// PublicConfigResponse 公共配置响应
|
// PublicConfigResponse 公共配置响应
|
||||||
|
|||||||
@@ -19,8 +19,8 @@ package health
|
|||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
|
"github.com/Rain-kl/Wavelet/internal/util"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"github.com/linux-do/credit/internal/util"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Health 健康检查
|
// Health 健康检查
|
||||||
|
|||||||
@@ -20,9 +20,9 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
|
||||||
|
"github.com/Rain-kl/Wavelet/internal/logger"
|
||||||
|
"github.com/Rain-kl/Wavelet/internal/model"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"github.com/linux-do/credit/internal/logger"
|
|
||||||
"github.com/linux-do/credit/internal/model"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func LogForAudit(ctx context.Context, user *model.User, c *gin.Context) {
|
func LogForAudit(ctx context.Context, user *model.User, c *gin.Context) {
|
||||||
|
|||||||
@@ -20,12 +20,12 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/Rain-kl/Wavelet/internal/common"
|
||||||
|
"github.com/Rain-kl/Wavelet/internal/db"
|
||||||
|
"github.com/Rain-kl/Wavelet/internal/model"
|
||||||
|
"github.com/Rain-kl/Wavelet/internal/otel_trace"
|
||||||
|
"github.com/Rain-kl/Wavelet/internal/util"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"github.com/linux-do/credit/internal/common"
|
|
||||||
"github.com/linux-do/credit/internal/db"
|
|
||||||
"github.com/linux-do/credit/internal/model"
|
|
||||||
"github.com/linux-do/credit/internal/otel_trace"
|
|
||||||
"github.com/linux-do/credit/internal/util"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type loginRequiredAuditLog struct {
|
type loginRequiredAuditLog struct {
|
||||||
|
|||||||
@@ -43,10 +43,10 @@ import (
|
|||||||
"gorm.io/driver/sqlite"
|
"gorm.io/driver/sqlite"
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
|
|
||||||
"github.com/linux-do/credit/internal/config"
|
"github.com/Rain-kl/Wavelet/internal/config"
|
||||||
"github.com/linux-do/credit/internal/db"
|
"github.com/Rain-kl/Wavelet/internal/db"
|
||||||
"github.com/linux-do/credit/internal/model"
|
"github.com/Rain-kl/Wavelet/internal/model"
|
||||||
"github.com/linux-do/credit/internal/util"
|
"github.com/Rain-kl/Wavelet/internal/util"
|
||||||
)
|
)
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -19,10 +19,10 @@ package oauth
|
|||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
|
"github.com/Rain-kl/Wavelet/internal/model"
|
||||||
|
"github.com/Rain-kl/Wavelet/internal/util"
|
||||||
"github.com/gin-contrib/sessions"
|
"github.com/gin-contrib/sessions"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"github.com/linux-do/credit/internal/model"
|
|
||||||
"github.com/linux-do/credit/internal/util"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type BasicUserInfo struct {
|
type BasicUserInfo struct {
|
||||||
|
|||||||
@@ -10,14 +10,14 @@ import (
|
|||||||
|
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
|
"github.com/Rain-kl/Wavelet/internal/common"
|
||||||
|
"github.com/Rain-kl/Wavelet/internal/db"
|
||||||
|
"github.com/Rain-kl/Wavelet/internal/model"
|
||||||
|
"github.com/Rain-kl/Wavelet/internal/util"
|
||||||
"github.com/coreos/go-oidc/v3/oidc"
|
"github.com/coreos/go-oidc/v3/oidc"
|
||||||
"github.com/gin-contrib/sessions"
|
"github.com/gin-contrib/sessions"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
"github.com/linux-do/credit/internal/common"
|
|
||||||
"github.com/linux-do/credit/internal/db"
|
|
||||||
"github.com/linux-do/credit/internal/model"
|
|
||||||
"github.com/linux-do/credit/internal/util"
|
|
||||||
"golang.org/x/oauth2"
|
"golang.org/x/oauth2"
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -21,10 +21,10 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
|
"github.com/Rain-kl/Wavelet/internal/db"
|
||||||
|
"github.com/Rain-kl/Wavelet/internal/model"
|
||||||
|
"github.com/Rain-kl/Wavelet/internal/storage"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"github.com/linux-do/credit/internal/db"
|
|
||||||
"github.com/linux-do/credit/internal/model"
|
|
||||||
"github.com/linux-do/credit/internal/storage"
|
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -33,15 +33,15 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/Rain-kl/Wavelet/internal/apps/oauth"
|
||||||
|
"github.com/Rain-kl/Wavelet/internal/config"
|
||||||
|
"github.com/Rain-kl/Wavelet/internal/db"
|
||||||
|
"github.com/Rain-kl/Wavelet/internal/db/idgen"
|
||||||
|
"github.com/Rain-kl/Wavelet/internal/logger"
|
||||||
|
"github.com/Rain-kl/Wavelet/internal/model"
|
||||||
|
"github.com/Rain-kl/Wavelet/internal/storage"
|
||||||
|
"github.com/Rain-kl/Wavelet/internal/util"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"github.com/linux-do/credit/internal/apps/oauth"
|
|
||||||
"github.com/linux-do/credit/internal/config"
|
|
||||||
"github.com/linux-do/credit/internal/db"
|
|
||||||
"github.com/linux-do/credit/internal/db/idgen"
|
|
||||||
"github.com/linux-do/credit/internal/logger"
|
|
||||||
"github.com/linux-do/credit/internal/model"
|
|
||||||
"github.com/linux-do/credit/internal/storage"
|
|
||||||
"github.com/linux-do/credit/internal/util"
|
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -29,13 +29,13 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/Rain-kl/Wavelet/internal/apps/oauth"
|
||||||
|
"github.com/Rain-kl/Wavelet/internal/db"
|
||||||
|
"github.com/Rain-kl/Wavelet/internal/model"
|
||||||
|
"github.com/Rain-kl/Wavelet/internal/storage"
|
||||||
|
"github.com/Rain-kl/Wavelet/internal/testhelper"
|
||||||
|
"github.com/Rain-kl/Wavelet/internal/util"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"github.com/linux-do/credit/internal/apps/oauth"
|
|
||||||
"github.com/linux-do/credit/internal/db"
|
|
||||||
"github.com/linux-do/credit/internal/model"
|
|
||||||
"github.com/linux-do/credit/internal/storage"
|
|
||||||
"github.com/linux-do/credit/internal/testhelper"
|
|
||||||
"github.com/linux-do/credit/internal/util"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type testResponse struct {
|
type testResponse struct {
|
||||||
|
|||||||
@@ -21,10 +21,10 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/linux-do/credit/internal/db"
|
"github.com/Rain-kl/Wavelet/internal/db"
|
||||||
"github.com/linux-do/credit/internal/model"
|
"github.com/Rain-kl/Wavelet/internal/model"
|
||||||
"github.com/linux-do/credit/internal/storage"
|
"github.com/Rain-kl/Wavelet/internal/storage"
|
||||||
"github.com/linux-do/credit/internal/task"
|
"github.com/Rain-kl/Wavelet/internal/task"
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -22,11 +22,11 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/linux-do/credit/internal/db"
|
"github.com/Rain-kl/Wavelet/internal/db"
|
||||||
"github.com/linux-do/credit/internal/model"
|
"github.com/Rain-kl/Wavelet/internal/model"
|
||||||
"github.com/linux-do/credit/internal/storage"
|
"github.com/Rain-kl/Wavelet/internal/storage"
|
||||||
"github.com/linux-do/credit/internal/task"
|
"github.com/Rain-kl/Wavelet/internal/task"
|
||||||
"github.com/linux-do/credit/internal/testhelper"
|
"github.com/Rain-kl/Wavelet/internal/testhelper"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -21,11 +21,11 @@ import (
|
|||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/Rain-kl/Wavelet/internal/apps/oauth"
|
||||||
|
"github.com/Rain-kl/Wavelet/internal/db"
|
||||||
|
"github.com/Rain-kl/Wavelet/internal/model"
|
||||||
|
"github.com/Rain-kl/Wavelet/internal/util"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"github.com/linux-do/credit/internal/apps/oauth"
|
|
||||||
"github.com/linux-do/credit/internal/db"
|
|
||||||
"github.com/linux-do/credit/internal/model"
|
|
||||||
"github.com/linux-do/credit/internal/util"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type createTokenRequest struct {
|
type createTokenRequest struct {
|
||||||
|
|||||||
@@ -10,14 +10,14 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/Rain-kl/Wavelet/internal/apps/oauth"
|
||||||
|
"github.com/Rain-kl/Wavelet/internal/common"
|
||||||
|
"github.com/Rain-kl/Wavelet/internal/db"
|
||||||
|
"github.com/Rain-kl/Wavelet/internal/model"
|
||||||
|
"github.com/Rain-kl/Wavelet/internal/task"
|
||||||
|
"github.com/Rain-kl/Wavelet/internal/util"
|
||||||
"github.com/gin-contrib/sessions"
|
"github.com/gin-contrib/sessions"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"github.com/linux-do/credit/internal/apps/oauth"
|
|
||||||
"github.com/linux-do/credit/internal/common"
|
|
||||||
"github.com/linux-do/credit/internal/db"
|
|
||||||
"github.com/linux-do/credit/internal/model"
|
|
||||||
"github.com/linux-do/credit/internal/task"
|
|
||||||
"github.com/linux-do/credit/internal/util"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type loginRequest struct {
|
type loginRequest struct {
|
||||||
|
|||||||
@@ -24,9 +24,9 @@ import (
|
|||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/linux-do/credit/internal/model"
|
"github.com/Rain-kl/Wavelet/internal/model"
|
||||||
"github.com/linux-do/credit/internal/task"
|
"github.com/Rain-kl/Wavelet/internal/task"
|
||||||
"github.com/linux-do/credit/internal/util/mail"
|
"github.com/Rain-kl/Wavelet/internal/util/mail"
|
||||||
)
|
)
|
||||||
|
|
||||||
// SendEmailPayload 邮件发送任务载荷
|
// SendEmailPayload 邮件发送任务载荷
|
||||||
|
|||||||
+1
-1
@@ -17,7 +17,7 @@ limitations under the License.
|
|||||||
package cmd
|
package cmd
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/linux-do/credit/internal/router"
|
"github.com/Rain-kl/Wavelet/internal/router"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ package cmd
|
|||||||
import (
|
import (
|
||||||
"log"
|
"log"
|
||||||
|
|
||||||
"github.com/linux-do/credit/internal/db/migrator"
|
"github.com/Rain-kl/Wavelet/internal/db/migrator"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ package cmd
|
|||||||
import (
|
import (
|
||||||
"log"
|
"log"
|
||||||
|
|
||||||
"github.com/linux-do/credit/internal/task/scheduler"
|
"github.com/Rain-kl/Wavelet/internal/task/scheduler"
|
||||||
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ package cmd
|
|||||||
import (
|
import (
|
||||||
"log"
|
"log"
|
||||||
|
|
||||||
"github.com/linux-do/credit/internal/task/worker"
|
"github.com/Rain-kl/Wavelet/internal/task/worker"
|
||||||
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ import (
|
|||||||
|
|
||||||
"github.com/ClickHouse/clickhouse-go/v2"
|
"github.com/ClickHouse/clickhouse-go/v2"
|
||||||
"github.com/ClickHouse/clickhouse-go/v2/lib/driver"
|
"github.com/ClickHouse/clickhouse-go/v2/lib/driver"
|
||||||
"github.com/linux-do/credit/internal/config"
|
"github.com/Rain-kl/Wavelet/internal/config"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
|||||||
@@ -19,8 +19,8 @@ package idgen
|
|||||||
import (
|
import (
|
||||||
"log"
|
"log"
|
||||||
|
|
||||||
|
"github.com/Rain-kl/Wavelet/internal/config"
|
||||||
"github.com/bwmarrin/snowflake"
|
"github.com/bwmarrin/snowflake"
|
||||||
"github.com/linux-do/credit/internal/config"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// 2025-12-01 00:00:00 UTC 的毫秒时间戳
|
// 2025-12-01 00:00:00 UTC 的毫秒时间戳
|
||||||
|
|||||||
@@ -21,11 +21,11 @@ import (
|
|||||||
"log"
|
"log"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/linux-do/credit/internal/model"
|
"github.com/Rain-kl/Wavelet/internal/model"
|
||||||
|
|
||||||
"github.com/linux-do/credit/internal/config"
|
"github.com/Rain-kl/Wavelet/internal/config"
|
||||||
"github.com/linux-do/credit/internal/db"
|
"github.com/Rain-kl/Wavelet/internal/db"
|
||||||
"github.com/linux-do/credit/internal/db/idgen"
|
"github.com/Rain-kl/Wavelet/internal/db/idgen"
|
||||||
)
|
)
|
||||||
|
|
||||||
func Migrate() {
|
func Migrate() {
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ import (
|
|||||||
"strconv"
|
"strconv"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/linux-do/credit/internal/config"
|
"github.com/Rain-kl/Wavelet/internal/config"
|
||||||
"go.opentelemetry.io/otel/attribute"
|
"go.opentelemetry.io/otel/attribute"
|
||||||
"gorm.io/driver/postgres"
|
"gorm.io/driver/postgres"
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/linux-do/credit/internal/logger"
|
"github.com/Rain-kl/Wavelet/internal/logger"
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
gormLogger "gorm.io/gorm/logger"
|
gormLogger "gorm.io/gorm/logger"
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/linux-do/credit/internal/config"
|
"github.com/Rain-kl/Wavelet/internal/config"
|
||||||
"github.com/redis/go-redis/extra/redisotel/v9"
|
"github.com/redis/go-redis/extra/redisotel/v9"
|
||||||
"github.com/redis/go-redis/v9"
|
"github.com/redis/go-redis/v9"
|
||||||
"go.opentelemetry.io/otel/attribute"
|
"go.opentelemetry.io/otel/attribute"
|
||||||
|
|||||||
@@ -92,8 +92,8 @@ func TestLogRingBuffer_QueryByCursorWithLimit(t *testing.T) {
|
|||||||
entries, hasMore := rb.Query(4, 2)
|
entries, hasMore := rb.Query(4, 2)
|
||||||
assert.True(t, hasMore)
|
assert.True(t, hasMore)
|
||||||
assert.Equal(t, 2, len(entries))
|
assert.Equal(t, 2, len(entries))
|
||||||
assert.Equal(t, "b", entries[0].Data)
|
assert.Equal(t, "c", entries[0].Data)
|
||||||
assert.Equal(t, "c", entries[1].Data)
|
assert.Equal(t, "d", entries[1].Data)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestLogRingBuffer_QueryEmpty(t *testing.T) {
|
func TestLogRingBuffer_QueryEmpty(t *testing.T) {
|
||||||
@@ -110,7 +110,9 @@ func TestLogRingBuffer_QueryNonExistentCursor(t *testing.T) {
|
|||||||
|
|
||||||
entries, hasMore := rb.Query(999, 10)
|
entries, hasMore := rb.Query(999, 10)
|
||||||
assert.False(t, hasMore)
|
assert.False(t, hasMore)
|
||||||
assert.Nil(t, entries)
|
assert.Equal(t, 2, len(entries))
|
||||||
|
assert.Equal(t, "a", entries[0].Data)
|
||||||
|
assert.Equal(t, "b", entries[1].Data)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestLogRingBuffer_Subscribe(t *testing.T) {
|
func TestLogRingBuffer_Subscribe(t *testing.T) {
|
||||||
@@ -177,11 +179,8 @@ func TestLogRingBuffer_QueryAfterOverflow(t *testing.T) {
|
|||||||
|
|
||||||
// Query by cursor - index 4 is "5", so cursor=4 should return index < 4
|
// Query by cursor - index 4 is "5", so cursor=4 should return index < 4
|
||||||
older, hasMore2 := rb.Query(4, 10)
|
older, hasMore2 := rb.Query(4, 10)
|
||||||
assert.True(t, hasMore2) // there are entries 0,1,2 but they've been overwritten...
|
assert.False(t, hasMore2)
|
||||||
// Actually after overflow, entries 0,1,2 are gone from ring, so index < 4 should return nothing
|
assert.Nil(t, older)
|
||||||
// Let's check: ring has indices 4,5,6. Query(cursor=4) looks for index < 4 → none in ring
|
|
||||||
_ = older
|
|
||||||
_ = hasMore2
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestLogRingBuffer_NextCursor(t *testing.T) {
|
func TestLogRingBuffer_NextCursor(t *testing.T) {
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ import (
|
|||||||
"path/filepath"
|
"path/filepath"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"github.com/linux-do/credit/internal/config"
|
"github.com/Rain-kl/Wavelet/internal/config"
|
||||||
"go.opentelemetry.io/otel/trace"
|
"go.opentelemetry.io/otel/trace"
|
||||||
"go.uber.org/zap"
|
"go.uber.org/zap"
|
||||||
"go.uber.org/zap/zapcore"
|
"go.uber.org/zap/zapcore"
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/linux-do/credit/internal/db"
|
"github.com/Rain-kl/Wavelet/internal/db"
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ import (
|
|||||||
"github.com/redis/go-redis/v9"
|
"github.com/redis/go-redis/v9"
|
||||||
"github.com/shopspring/decimal"
|
"github.com/shopspring/decimal"
|
||||||
|
|
||||||
"github.com/linux-do/credit/internal/db"
|
"github.com/Rain-kl/Wavelet/internal/db"
|
||||||
)
|
)
|
||||||
|
|
||||||
// 配置键常量 - 所有系统配置的 key 定义
|
// 配置键常量 - 所有系统配置的 key 定义
|
||||||
|
|||||||
@@ -21,8 +21,8 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/linux-do/credit/internal/db"
|
"github.com/Rain-kl/Wavelet/internal/db"
|
||||||
"github.com/linux-do/credit/internal/db/idgen"
|
"github.com/Rain-kl/Wavelet/internal/db/idgen"
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -21,13 +21,31 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/linux-do/credit/internal/testhelper"
|
"github.com/Rain-kl/Wavelet/internal/db"
|
||||||
|
"github.com/glebarez/sqlite"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
"gorm.io/gorm"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func setupTaskExecutionTestEnvironment(t *testing.T) func() {
|
||||||
|
sqliteDB, err := gorm.Open(sqlite.Open(":memory:"), &gorm.Config{
|
||||||
|
DisableForeignKeyConstraintWhenMigrating: true,
|
||||||
|
})
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
err = sqliteDB.AutoMigrate(&TaskExecution{})
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
db.SetDB(sqliteDB)
|
||||||
|
|
||||||
|
return func() {
|
||||||
|
db.SetDB(nil)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestCreateTaskExecution(t *testing.T) {
|
func TestCreateTaskExecution(t *testing.T) {
|
||||||
_, _, cleanup := testhelper.SetupTestEnvironment(t)
|
cleanup := setupTaskExecutionTestEnvironment(t)
|
||||||
defer cleanup()
|
defer cleanup()
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
|
|
||||||
@@ -51,7 +69,7 @@ func TestCreateTaskExecution(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestGetTaskExecutionByTaskID(t *testing.T) {
|
func TestGetTaskExecutionByTaskID(t *testing.T) {
|
||||||
_, _, cleanup := testhelper.SetupTestEnvironment(t)
|
cleanup := setupTaskExecutionTestEnvironment(t)
|
||||||
defer cleanup()
|
defer cleanup()
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
|
|
||||||
@@ -83,7 +101,7 @@ func TestGetTaskExecutionByTaskID(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestGetTaskExecutionByID(t *testing.T) {
|
func TestGetTaskExecutionByID(t *testing.T) {
|
||||||
_, _, cleanup := testhelper.SetupTestEnvironment(t)
|
cleanup := setupTaskExecutionTestEnvironment(t)
|
||||||
defer cleanup()
|
defer cleanup()
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
|
|
||||||
@@ -104,7 +122,7 @@ func TestGetTaskExecutionByID(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestUpdateTaskExecution(t *testing.T) {
|
func TestUpdateTaskExecution(t *testing.T) {
|
||||||
_, _, cleanup := testhelper.SetupTestEnvironment(t)
|
cleanup := setupTaskExecutionTestEnvironment(t)
|
||||||
defer cleanup()
|
defer cleanup()
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
|
|
||||||
@@ -149,7 +167,7 @@ func TestUpdateTaskExecution(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestUpdateTaskExecutionFailed(t *testing.T) {
|
func TestUpdateTaskExecutionFailed(t *testing.T) {
|
||||||
_, _, cleanup := testhelper.SetupTestEnvironment(t)
|
cleanup := setupTaskExecutionTestEnvironment(t)
|
||||||
defer cleanup()
|
defer cleanup()
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
|
|
||||||
@@ -183,7 +201,7 @@ func TestUpdateTaskExecutionFailed(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestAppendTaskExecutionLog(t *testing.T) {
|
func TestAppendTaskExecutionLog(t *testing.T) {
|
||||||
_, _, cleanup := testhelper.SetupTestEnvironment(t)
|
cleanup := setupTaskExecutionTestEnvironment(t)
|
||||||
defer cleanup()
|
defer cleanup()
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
|
|
||||||
@@ -216,7 +234,7 @@ func TestAppendTaskExecutionLog(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestAppendTaskExecutionLogNonExistent(t *testing.T) {
|
func TestAppendTaskExecutionLogNonExistent(t *testing.T) {
|
||||||
_, _, cleanup := testhelper.SetupTestEnvironment(t)
|
cleanup := setupTaskExecutionTestEnvironment(t)
|
||||||
defer cleanup()
|
defer cleanup()
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
|
|
||||||
@@ -227,7 +245,7 @@ func TestAppendTaskExecutionLogNonExistent(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestListTaskExecutions(t *testing.T) {
|
func TestListTaskExecutions(t *testing.T) {
|
||||||
_, _, cleanup := testhelper.SetupTestEnvironment(t)
|
cleanup := setupTaskExecutionTestEnvironment(t)
|
||||||
defer cleanup()
|
defer cleanup()
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
|
|
||||||
@@ -284,7 +302,7 @@ func TestListTaskExecutions(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestListTaskExecutionsDefaultPaging(t *testing.T) {
|
func TestListTaskExecutionsDefaultPaging(t *testing.T) {
|
||||||
_, _, cleanup := testhelper.SetupTestEnvironment(t)
|
cleanup := setupTaskExecutionTestEnvironment(t)
|
||||||
defer cleanup()
|
defer cleanup()
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
|
|
||||||
|
|||||||
@@ -22,8 +22,8 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/linux-do/credit/internal/common"
|
"github.com/Rain-kl/Wavelet/internal/common"
|
||||||
"github.com/linux-do/credit/internal/util"
|
"github.com/Rain-kl/Wavelet/internal/util"
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -18,9 +18,10 @@ package otel_trace
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"log"
|
||||||
|
|
||||||
"go.opentelemetry.io/otel"
|
"go.opentelemetry.io/otel"
|
||||||
"go.opentelemetry.io/otel/trace"
|
"go.opentelemetry.io/otel/trace"
|
||||||
"log"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var Tracer trace.Tracer
|
var Tracer trace.Tracer
|
||||||
@@ -40,7 +41,7 @@ func init() {
|
|||||||
otel.SetTracerProvider(tracerProvider)
|
otel.SetTracerProvider(tracerProvider)
|
||||||
|
|
||||||
// 初始化 Tracer
|
// 初始化 Tracer
|
||||||
Tracer = tracerProvider.Tracer("github.com/linux-do/credit")
|
Tracer = tracerProvider.Tracer("github.com/Rain-kl/Wavelet")
|
||||||
}
|
}
|
||||||
|
|
||||||
func Shutdown(ctx context.Context) {
|
func Shutdown(ctx context.Context) {
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
"github.com/linux-do/credit/internal/config"
|
"github.com/Rain-kl/Wavelet/internal/config"
|
||||||
"go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc"
|
"go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc"
|
||||||
"go.opentelemetry.io/otel/sdk/resource"
|
"go.opentelemetry.io/otel/sdk/resource"
|
||||||
sdktrace "go.opentelemetry.io/otel/sdk/trace"
|
sdktrace "go.opentelemetry.io/otel/sdk/trace"
|
||||||
|
|||||||
@@ -21,11 +21,11 @@ import (
|
|||||||
"strconv"
|
"strconv"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/Rain-kl/Wavelet/internal/config"
|
||||||
|
"github.com/Rain-kl/Wavelet/internal/logger"
|
||||||
|
"github.com/Rain-kl/Wavelet/internal/model"
|
||||||
|
"github.com/Rain-kl/Wavelet/internal/otel_trace"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"github.com/linux-do/credit/internal/config"
|
|
||||||
"github.com/linux-do/credit/internal/logger"
|
|
||||||
"github.com/linux-do/credit/internal/model"
|
|
||||||
"github.com/linux-do/credit/internal/otel_trace"
|
|
||||||
"go.opentelemetry.io/otel/codes"
|
"go.opentelemetry.io/otel/codes"
|
||||||
"go.opentelemetry.io/otel/trace"
|
"go.opentelemetry.io/otel/trace"
|
||||||
)
|
)
|
||||||
|
|||||||
+19
-19
@@ -27,29 +27,29 @@ import (
|
|||||||
"syscall"
|
"syscall"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/linux-do/credit/internal/apps/admin"
|
"github.com/Rain-kl/Wavelet/internal/apps/admin"
|
||||||
admin_auth_source "github.com/linux-do/credit/internal/apps/admin/auth_source"
|
admin_auth_source "github.com/Rain-kl/Wavelet/internal/apps/admin/auth_source"
|
||||||
admin_logs "github.com/linux-do/credit/internal/apps/admin/logs"
|
admin_logs "github.com/Rain-kl/Wavelet/internal/apps/admin/logs"
|
||||||
admin_status "github.com/linux-do/credit/internal/apps/admin/status"
|
admin_status "github.com/Rain-kl/Wavelet/internal/apps/admin/status"
|
||||||
admin_task "github.com/linux-do/credit/internal/apps/admin/task"
|
admin_task "github.com/Rain-kl/Wavelet/internal/apps/admin/task"
|
||||||
admin_user "github.com/linux-do/credit/internal/apps/admin/user"
|
admin_user "github.com/Rain-kl/Wavelet/internal/apps/admin/user"
|
||||||
capApp "github.com/linux-do/credit/internal/apps/cap"
|
capApp "github.com/Rain-kl/Wavelet/internal/apps/cap"
|
||||||
publicconfig "github.com/linux-do/credit/internal/apps/config"
|
publicconfig "github.com/Rain-kl/Wavelet/internal/apps/config"
|
||||||
"github.com/linux-do/credit/internal/apps/health"
|
"github.com/Rain-kl/Wavelet/internal/apps/health"
|
||||||
"github.com/linux-do/credit/internal/apps/upload"
|
"github.com/Rain-kl/Wavelet/internal/apps/upload"
|
||||||
"github.com/linux-do/credit/internal/apps/user"
|
"github.com/Rain-kl/Wavelet/internal/apps/user"
|
||||||
"github.com/linux-do/credit/internal/model"
|
"github.com/Rain-kl/Wavelet/internal/model"
|
||||||
"github.com/linux-do/credit/internal/util"
|
"github.com/Rain-kl/Wavelet/internal/util"
|
||||||
capUtil "github.com/linux-do/credit/internal/util/cap"
|
capUtil "github.com/Rain-kl/Wavelet/internal/util/cap"
|
||||||
|
|
||||||
|
_ "github.com/Rain-kl/Wavelet/docs"
|
||||||
|
"github.com/Rain-kl/Wavelet/internal/apps/admin/system_config"
|
||||||
|
"github.com/Rain-kl/Wavelet/internal/apps/oauth"
|
||||||
|
"github.com/Rain-kl/Wavelet/internal/config"
|
||||||
|
"github.com/Rain-kl/Wavelet/internal/otel_trace"
|
||||||
"github.com/gin-contrib/sessions"
|
"github.com/gin-contrib/sessions"
|
||||||
"github.com/gin-contrib/sessions/redis"
|
"github.com/gin-contrib/sessions/redis"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
_ "github.com/linux-do/credit/docs"
|
|
||||||
"github.com/linux-do/credit/internal/apps/admin/system_config"
|
|
||||||
"github.com/linux-do/credit/internal/apps/oauth"
|
|
||||||
"github.com/linux-do/credit/internal/config"
|
|
||||||
"github.com/linux-do/credit/internal/otel_trace"
|
|
||||||
swaggerFiles "github.com/swaggo/files"
|
swaggerFiles "github.com/swaggo/files"
|
||||||
ginSwagger "github.com/swaggo/gin-swagger"
|
ginSwagger "github.com/swaggo/gin-swagger"
|
||||||
"go.opentelemetry.io/contrib/instrumentation/github.com/gin-gonic/gin/otelgin"
|
"go.opentelemetry.io/contrib/instrumentation/github.com/gin-gonic/gin/otelgin"
|
||||||
|
|||||||
@@ -27,9 +27,9 @@ import (
|
|||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/linux-do/credit/internal/config"
|
"github.com/Rain-kl/Wavelet/internal/config"
|
||||||
"github.com/linux-do/credit/internal/logger"
|
"github.com/Rain-kl/Wavelet/internal/logger"
|
||||||
"github.com/linux-do/credit/internal/otel_trace"
|
"github.com/Rain-kl/Wavelet/internal/otel_trace"
|
||||||
"go.opentelemetry.io/otel/codes"
|
"go.opentelemetry.io/otel/codes"
|
||||||
"go.opentelemetry.io/otel/trace"
|
"go.opentelemetry.io/otel/trace"
|
||||||
"golang.org/x/sync/singleflight"
|
"golang.org/x/sync/singleflight"
|
||||||
|
|||||||
@@ -24,13 +24,13 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/Rain-kl/Wavelet/internal/config"
|
||||||
|
"github.com/Rain-kl/Wavelet/internal/otel_trace"
|
||||||
|
"github.com/Rain-kl/Wavelet/internal/util"
|
||||||
"github.com/aws/aws-sdk-go-v2/aws"
|
"github.com/aws/aws-sdk-go-v2/aws"
|
||||||
awsconfig "github.com/aws/aws-sdk-go-v2/config"
|
awsconfig "github.com/aws/aws-sdk-go-v2/config"
|
||||||
"github.com/aws/aws-sdk-go-v2/credentials"
|
"github.com/aws/aws-sdk-go-v2/credentials"
|
||||||
"github.com/aws/aws-sdk-go-v2/service/s3"
|
"github.com/aws/aws-sdk-go-v2/service/s3"
|
||||||
"github.com/linux-do/credit/internal/config"
|
|
||||||
"github.com/linux-do/credit/internal/otel_trace"
|
|
||||||
"github.com/linux-do/credit/internal/util"
|
|
||||||
"go.opentelemetry.io/otel/attribute"
|
"go.opentelemetry.io/otel/attribute"
|
||||||
"go.opentelemetry.io/otel/codes"
|
"go.opentelemetry.io/otel/codes"
|
||||||
"go.opentelemetry.io/otel/trace"
|
"go.opentelemetry.io/otel/trace"
|
||||||
|
|||||||
@@ -21,11 +21,11 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/Rain-kl/Wavelet/internal/db/idgen"
|
||||||
|
"github.com/Rain-kl/Wavelet/internal/logger"
|
||||||
|
"github.com/Rain-kl/Wavelet/internal/model"
|
||||||
|
"github.com/Rain-kl/Wavelet/internal/otel_trace"
|
||||||
"github.com/hibiken/asynq"
|
"github.com/hibiken/asynq"
|
||||||
"github.com/linux-do/credit/internal/db/idgen"
|
|
||||||
"github.com/linux-do/credit/internal/logger"
|
|
||||||
"github.com/linux-do/credit/internal/model"
|
|
||||||
"github.com/linux-do/credit/internal/otel_trace"
|
|
||||||
"go.opentelemetry.io/otel/attribute"
|
"go.opentelemetry.io/otel/attribute"
|
||||||
"go.opentelemetry.io/otel/codes"
|
"go.opentelemetry.io/otel/codes"
|
||||||
"go.opentelemetry.io/otel/trace"
|
"go.opentelemetry.io/otel/trace"
|
||||||
|
|||||||
@@ -22,9 +22,9 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/Rain-kl/Wavelet/internal/model"
|
||||||
|
"github.com/Rain-kl/Wavelet/internal/testhelper"
|
||||||
"github.com/hibiken/asynq"
|
"github.com/hibiken/asynq"
|
||||||
"github.com/linux-do/credit/internal/model"
|
|
||||||
"github.com/linux-do/credit/internal/testhelper"
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
@@ -64,10 +64,19 @@ func failHandler() *mockHandler {
|
|||||||
const testTaskType = "test:mock_task"
|
const testTaskType = "test:mock_task"
|
||||||
|
|
||||||
func setupTest(t *testing.T) func() {
|
func setupTest(t *testing.T) func() {
|
||||||
_, _, cleanup := testhelper.SetupTestEnvironment(t)
|
_, mr, cleanup := testhelper.SetupTestEnvironment(t)
|
||||||
|
AsynqClient = asynq.NewClient(asynq.RedisClientOpt{
|
||||||
|
Addr: mr.Addr(),
|
||||||
|
})
|
||||||
// 注册测试用 handler
|
// 注册测试用 handler
|
||||||
RegisterHandler(testTaskType, successHandler())
|
RegisterHandler(testTaskType, successHandler())
|
||||||
return cleanup
|
return func() {
|
||||||
|
if AsynqClient != nil {
|
||||||
|
AsynqClient.Close()
|
||||||
|
AsynqClient = nil
|
||||||
|
}
|
||||||
|
cleanup()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestRegisterAndGetHandler(t *testing.T) {
|
func TestRegisterAndGetHandler(t *testing.T) {
|
||||||
@@ -156,11 +165,6 @@ func TestProcessTaskSuccess(t *testing.T) {
|
|||||||
err := model.CreateTaskExecution(ctx, execution)
|
err := model.CreateTaskExecution(ctx, execution)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
// 模拟 Asynq Task
|
|
||||||
asynqTask := asynq.NewTask(testTaskType, nil)
|
|
||||||
// 使用 ResultWriter 设置 TaskID
|
|
||||||
rw := asynq.NewResultWriter()
|
|
||||||
rw.SetTaskID("process_success_001")
|
|
||||||
// 通过 asynq 的 Task 不能直接设置 taskID,ProcessTask 通过 t.ResultWriter().TaskID() 获取
|
// 通过 asynq 的 Task 不能直接设置 taskID,ProcessTask 通过 t.ResultWriter().TaskID() 获取
|
||||||
// 但 asynq.Task 在没有经过 asynq server 的情况下 ResultWriter 可能为 nil
|
// 但 asynq.Task 在没有经过 asynq server 的情况下 ResultWriter 可能为 nil
|
||||||
// 我们需要在 ProcessTask 内部改用 taskID 注入的方式测试
|
// 我们需要在 ProcessTask 内部改用 taskID 注入的方式测试
|
||||||
|
|||||||
@@ -0,0 +1,29 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2026 linux.do
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package handlers
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/Rain-kl/Wavelet/internal/apps/upload"
|
||||||
|
"github.com/Rain-kl/Wavelet/internal/apps/user"
|
||||||
|
"github.com/Rain-kl/Wavelet/internal/task"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Register registers all built-in task handlers.
|
||||||
|
func Register() {
|
||||||
|
task.RegisterHandler(task.CleanupUnusedUploadsTask, &upload.CleanupUnusedUploadsHandler{})
|
||||||
|
task.RegisterHandler(task.SendEmailTask, &user.SendEmailHandler{})
|
||||||
|
}
|
||||||
@@ -21,8 +21,8 @@ import (
|
|||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/linux-do/credit/internal/config"
|
"github.com/Rain-kl/Wavelet/internal/config"
|
||||||
"github.com/linux-do/credit/internal/task"
|
"github.com/Rain-kl/Wavelet/internal/task"
|
||||||
|
|
||||||
"github.com/hibiken/asynq"
|
"github.com/hibiken/asynq"
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -17,8 +17,8 @@ limitations under the License.
|
|||||||
package task
|
package task
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"github.com/Rain-kl/Wavelet/internal/config"
|
||||||
"github.com/hibiken/asynq"
|
"github.com/hibiken/asynq"
|
||||||
"github.com/linux-do/credit/internal/config"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// RedisOpt asynq Redis 连接配置(兼容 Standalone/Sentinel/Cluster)
|
// RedisOpt asynq Redis 连接配置(兼容 Standalone/Sentinel/Cluster)
|
||||||
|
|||||||
@@ -19,17 +19,15 @@ package worker
|
|||||||
import (
|
import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/Rain-kl/Wavelet/internal/config"
|
||||||
|
"github.com/Rain-kl/Wavelet/internal/task"
|
||||||
|
taskhandlers "github.com/Rain-kl/Wavelet/internal/task/handlers"
|
||||||
"github.com/hibiken/asynq"
|
"github.com/hibiken/asynq"
|
||||||
"github.com/linux-do/credit/internal/apps/upload"
|
|
||||||
"github.com/linux-do/credit/internal/apps/user"
|
|
||||||
"github.com/linux-do/credit/internal/config"
|
|
||||||
"github.com/linux-do/credit/internal/task"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
// 注册所有任务处理器
|
// 注册所有任务处理器
|
||||||
task.RegisterHandler(task.CleanupUnusedUploadsTask, &upload.CleanupUnusedUploadsHandler{})
|
taskhandlers.Register()
|
||||||
task.RegisterHandler(task.SendEmailTask, &user.SendEmailHandler{})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// StartWorker 启动任务处理服务器
|
// StartWorker 启动任务处理服务器
|
||||||
|
|||||||
@@ -20,12 +20,10 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/Rain-kl/Wavelet/internal/db"
|
||||||
|
"github.com/Rain-kl/Wavelet/internal/model"
|
||||||
"github.com/alicebob/miniredis/v2"
|
"github.com/alicebob/miniredis/v2"
|
||||||
"github.com/glebarez/sqlite"
|
"github.com/glebarez/sqlite"
|
||||||
"github.com/hibiken/asynq"
|
|
||||||
"github.com/linux-do/credit/internal/db"
|
|
||||||
"github.com/linux-do/credit/internal/model"
|
|
||||||
"github.com/linux-do/credit/internal/task"
|
|
||||||
"github.com/redis/go-redis/v9"
|
"github.com/redis/go-redis/v9"
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
)
|
)
|
||||||
@@ -69,11 +67,6 @@ func SetupTestEnvironment(t *testing.T) (*gorm.DB, *miniredis.Miniredis, func())
|
|||||||
})
|
})
|
||||||
db.Redis = redisClient
|
db.Redis = redisClient
|
||||||
|
|
||||||
// Hook up AsynqClient to miniredis
|
|
||||||
task.AsynqClient = asynq.NewClient(asynq.RedisClientOpt{
|
|
||||||
Addr: mr.Addr(),
|
|
||||||
})
|
|
||||||
|
|
||||||
// Seed default configurations
|
// Seed default configurations
|
||||||
seedDefaultConfigs(t, sqliteDB)
|
seedDefaultConfigs(t, sqliteDB)
|
||||||
|
|
||||||
@@ -84,7 +77,6 @@ func SetupTestEnvironment(t *testing.T) (*gorm.DB, *miniredis.Miniredis, func())
|
|||||||
// Reset database and Redis references
|
// Reset database and Redis references
|
||||||
db.SetDB(nil)
|
db.SetDB(nil)
|
||||||
db.Redis = nil
|
db.Redis = nil
|
||||||
task.AsynqClient = nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return sqliteDB, mr, cleanup
|
return sqliteDB, mr, cleanup
|
||||||
|
|||||||
@@ -9,9 +9,9 @@ import (
|
|||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/linux-do/credit/internal/config"
|
"github.com/Rain-kl/Wavelet/internal/config"
|
||||||
"github.com/linux-do/credit/internal/db"
|
"github.com/Rain-kl/Wavelet/internal/db"
|
||||||
"github.com/linux-do/credit/internal/model"
|
"github.com/Rain-kl/Wavelet/internal/model"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Config holds settings for the CAPTCHA manager
|
// Config holds settings for the CAPTCHA manager
|
||||||
|
|||||||
@@ -17,8 +17,8 @@ limitations under the License.
|
|||||||
package util
|
package util
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"github.com/Rain-kl/Wavelet/internal/config"
|
||||||
"github.com/gin-contrib/sessions"
|
"github.com/gin-contrib/sessions"
|
||||||
"github.com/linux-do/credit/internal/config"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func GetSessionOptions(maxAge int) sessions.Options {
|
func GetSessionOptions(maxAge int) sessions.Options {
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ package util
|
|||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
|
|
||||||
"github.com/linux-do/credit/internal/common"
|
"github.com/Rain-kl/Wavelet/internal/common"
|
||||||
"github.com/shopspring/decimal"
|
"github.com/shopspring/decimal"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user