Commit da212b35 authored by vicotor's avatar vicotor

update for lock

parent b15b3009
......@@ -19,9 +19,10 @@ var client *supabase.Client
func init() {
var API_URL = "http://43.198.54.207:8000"
var API_KEY = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyAgCiAgICAicm9sZSI6ICJzZXJ2aWNlX3JvbGUiLAogICAgImlzcyI6ICJzdXBhYmFzZS1kZW1vIiwKICAgICJpYXQiOiAxNjQxNzY5MjAwLAogICAgImV4cCI6IDE3OTk1MzU2MDAKfQ.DaYlNEoUrrEn2Ig7tqibS-PHK5vgusbcbo7X36XVt4Q"
//var API_URL = "http://43.198.54.207:8000"
//var API_KEY = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyAgCiAgICAicm9sZSI6ICJzZXJ2aWNlX3JvbGUiLAogICAgImlzcyI6ICJzdXBhYmFzZS1kZW1vIiwKICAgICJpYXQiOiAxNjQxNzY5MjAwLAogICAgImV4cCI6IDE3OTk1MzU2MDAKfQ.DaYlNEoUrrEn2Ig7tqibS-PHK5vgusbcbo7X36XVt4Q"
var API_URL = "https://api.iaon.ai"
var API_KEY = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InZieHR2amZmaHNpcm55eGpjdWt1Iiwicm9sZSI6InNlcnZpY2Vfcm9sZSIsImlhdCI6MTcyMjUxNjU2NCwiZXhwIjoyMDM4MDkyNTY0fQ.1IvdUdoQu5yNHllvFQA_tFGDSbydAB5bjFSCxXcZ260"
for {
cli, err := supabase.NewClient(API_URL, API_KEY, &supabase.ClientOptions{
Schema: "twitter",
......
......@@ -2,55 +2,55 @@ module code.wuban.net.cn/odysseus/twitter_syncer
go 1.22.4
require (
github.com/dghubble/oauth1 v0.7.3
github.com/g8rswimmer/go-twitter/v2 v2.1.5
github.com/gofiber/fiber/v2 v2.52.5
github.com/imperatrona/twitter-scraper v0.0.14
github.com/supabase-community/postgrest-go v0.0.11
github.com/supabase-community/supabase-go v0.0.4
github.com/swaggo/swag v1.16.3
golang.org/x/time v0.6.0
)
require (
github.com/AlexEidt/Vidio v1.5.1 // indirect
github.com/KyleBanks/depth v1.2.1 // indirect
github.com/PuerkitoBio/purell v1.2.1 // indirect
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect
github.com/andybalholm/brotli v1.1.0 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.4 // indirect
github.com/dghubble/oauth1 v0.7.3 // indirect
github.com/g8rswimmer/go-twitter/v2 v2.1.5 // indirect
github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 // indirect
github.com/go-openapi/analysis v0.21.4 // indirect
github.com/go-openapi/errors v0.20.4 // indirect
github.com/go-openapi/jsonpointer v0.21.0 // indirect
github.com/go-openapi/jsonreference v0.21.0 // indirect
github.com/go-openapi/loads v0.21.2 // indirect
github.com/go-openapi/runtime v0.26.2 // indirect
github.com/go-openapi/spec v0.21.0 // indirect
github.com/go-openapi/strfmt v0.21.8 // indirect
github.com/go-openapi/swag v0.23.0 // indirect
github.com/gofiber/fiber/v2 v2.52.5 // indirect
github.com/gofiber/swagger v1.1.0 // indirect
github.com/go-openapi/validate v0.22.3 // indirect
github.com/gofiber/contrib/swagger v1.2.0 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/imperatrona/twitter-scraper v0.0.9 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/klauspost/compress v1.17.9 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mattn/go-runewidth v0.0.16 // indirect
github.com/michimani/gotwi v0.15.0 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/oklog/ulid v1.3.1 // indirect
github.com/rivo/uniseg v0.4.7 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/shurcooL/sanitized_anchor_name v1.0.0 // indirect
github.com/supabase-community/functions-go v0.0.0-20220927045802-22373e6cb51d // indirect
github.com/supabase-community/gotrue-go v1.2.0 // indirect
github.com/supabase-community/postgrest-go v0.0.11 // indirect
github.com/supabase-community/storage-go v0.7.0 // indirect
github.com/supabase-community/supabase-go v0.0.4 // indirect
github.com/swaggo/files/v2 v2.0.1 // indirect
github.com/swaggo/swag v1.16.3 // indirect
github.com/tomnomnom/linkheader v0.0.0-20180905144013-02ca5825eb80 // indirect
github.com/urfave/cli/v2 v2.27.3 // indirect
github.com/valyala/bytebufferpool v1.0.0 // indirect
github.com/valyala/fasthttp v1.55.0 // indirect
github.com/valyala/tcplisten v1.0.0 // indirect
github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1 // indirect
golang.org/x/net v0.27.0 // indirect
golang.org/x/oauth2 v0.22.0 // indirect
golang.org/x/sys v0.22.0 // indirect
golang.org/x/text v0.16.0 // indirect
golang.org/x/time v0.6.0 // indirect
go.mongodb.org/mongo-driver v1.13.1 // indirect
golang.org/x/net v0.29.0 // indirect
golang.org/x/sys v0.25.0 // indirect
golang.org/x/tools v0.23.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
sigs.k8s.io/yaml v1.4.0 // indirect
)
replace github.com/imperatrona/twitter-scraper => ../twitter-scraper
This diff is collapsed.
......@@ -8,9 +8,9 @@ import (
// "github.com/gofiber/fiber/v2/middleware/cors"
// "github.com/gofiber/swagger"
"github.com/gofiber/contrib/swagger"
"github.com/gofiber/fiber/v2"
"github.com/gofiber/fiber/v2/middleware/cors"
"github.com/gofiber/swagger"
//"github.com/gofiber/swagger"
......@@ -46,23 +46,19 @@ func main() {
// taskIn = taskInStream
app := fiber.New()
app.Use(cors.New())
app.Static("/swagger/docs", "./docs")
app.Get("/swagger/*", swagger.New(swagger.Config{ // custom
URL: "http://43.198.54.207:8001/swagger/docs/swagger.yaml", //http://124.193.167.71:8000/
DeepLinking: false,
// Expand ("list") or Collapse ("none") tag groups by default
DocExpansion: "none",
// Prefill OAuth ClientId on Authorize popup
// OAuth: &swagger.OAuthConfig{
// AppName: "OAuth Provider",
// ClientId: "21bb4edc-05a7-4afc-86f1-2e151e4ba6e2",
// },
// Ability to change OAuth2 redirect uri location
//OAuth2RedirectUrl: "http://localhost:8080/swagger/oauth2-redirect.html",
}))
//app.Static("/swagger/docs", "./docs")
cfg := swagger.Config{
BasePath: "/",
FilePath: "./docs/swagger.yaml",
Path: "swagger",
Title: "Swagger API Docs",
}
app.Use(swagger.New(cfg))
app.Post("/project", Project)
app.Post("/task/add", TaskAdd)
......
......@@ -25,6 +25,7 @@ func init() {
func (w *Work) StopJob(userId, taskType string) error {
w.Lock.Lock()
defer w.Lock.Unlock()
if v, ok := w.Task[userId+"-"+taskType]; ok {
close(v)
......@@ -36,13 +37,13 @@ func (w *Work) StopJob(userId, taskType string) error {
// done := w.RunJob(t)
// w.Task[t.UserId+"-"+t.TaskType] = done
w.Lock.Unlock()
return nil
}
func (w *Work) AddJob(t TaskJob) error {
w.Lock.Lock()
defer w.Lock.Unlock()
if _, ok := w.Task[t.UserId+"-"+t.TaskType]; ok {
return fmt.Errorf("%s has run", t.UserId+"-"+t.TaskId+"-"+t.TaskType)
......@@ -52,8 +53,6 @@ func (w *Work) AddJob(t TaskJob) error {
w.Task[t.UserId+"-"+t.TaskType] = done
w.Lock.Unlock()
return nil
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment