Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
ai-api-mgr
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Odysseus
ai-api-mgr
Commits
8bfc1b29
Commit
8bfc1b29
authored
Feb 29, 2024
by
Your Name
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add log server
parent
fe5c3f65
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
1762 additions
and
7 deletions
+1762
-7
go.mod
go.mod
+38
-1
go.sum
go.sum
+1696
-0
main.go
main.go
+28
-6
No files found.
go.mod
View file @
8bfc1b29
...
@@ -26,21 +26,29 @@ require (
...
@@ -26,21 +26,29 @@ require (
github.com/KyleBanks/depth v1.2.1 // indirect
github.com/KyleBanks/depth v1.2.1 // indirect
github.com/andybalholm/brotli v1.0.5 // indirect
github.com/andybalholm/brotli v1.0.5 // indirect
github.com/astaxie/beego v1.12.3 // indirect
github.com/astaxie/beego v1.12.3 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/dennwc/varint v1.0.0 // indirect
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
github.com/eapache/go-resiliency v1.4.0 // indirect
github.com/eapache/go-resiliency v1.4.0 // indirect
github.com/eapache/go-xerial-snappy v0.0.0-20230731223053-c322873962e3 // indirect
github.com/eapache/go-xerial-snappy v0.0.0-20230731223053-c322873962e3 // indirect
github.com/eapache/queue v1.1.0 // indirect
github.com/eapache/queue v1.1.0 // indirect
github.com/go-kit/kit v0.10.0 // indirect
github.com/go-kit/log v0.2.0 // indirect
github.com/go-logfmt/logfmt v0.5.1 // indirect
github.com/go-openapi/jsonpointer v0.19.5 // indirect
github.com/go-openapi/jsonpointer v0.19.5 // indirect
github.com/go-openapi/jsonreference v0.20.0 // indirect
github.com/go-openapi/jsonreference v0.20.0 // indirect
github.com/go-openapi/spec v0.20.8 // indirect
github.com/go-openapi/spec v0.20.8 // indirect
github.com/go-openapi/swag v0.22.3 // indirect
github.com/go-openapi/swag v0.22.3 // indirect
github.com/go-sql-driver/mysql v1.7.1 // indirect
github.com/go-sql-driver/mysql v1.7.1 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/gomodule/redigo v2.0.0+incompatible // indirect
github.com/gomodule/redigo v2.0.0+incompatible // indirect
github.com/google/uuid v1.5.0 // indirect
github.com/google/uuid v1.5.0 // indirect
github.com/hashicorp/errwrap v1.0.0 // indirect
github.com/grafana/loki-client-go v0.0.0-20230116142646-e7494d0ef70c // indirect
github.com/grafana/regexp v0.0.0-20220304095617-2e8d9baf4ac2 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/go-multierror v1.1.1 // indirect
github.com/hashicorp/go-multierror v1.1.1 // indirect
github.com/hashicorp/go-uuid v1.0.3 // indirect
github.com/hashicorp/go-uuid v1.0.3 // indirect
github.com/hashicorp/golang-lru v0.5.4 // indirect
github.com/hashicorp/golang-lru v0.5.4 // indirect
...
@@ -50,26 +58,55 @@ require (
...
@@ -50,26 +58,55 @@ require (
github.com/jcmturner/gokrb5/v8 v8.4.4 // indirect
github.com/jcmturner/gokrb5/v8 v8.4.4 // indirect
github.com/jcmturner/rpc/v2 v2.0.3 // indirect
github.com/jcmturner/rpc/v2 v2.0.3 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/jpillora/backoff v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/klauspost/compress v1.17.0 // indirect
github.com/klauspost/compress v1.17.0 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mattn/go-runewidth v0.0.15 // indirect
github.com/mattn/go-runewidth v0.0.15 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 // indirect
github.com/mitchellh/mapstructure v1.4.3 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f // indirect
github.com/odysseus/service-registry v0.0.0-00010101000000-000000000000 // indirect
github.com/odysseus/service-registry v0.0.0-00010101000000-000000000000 // indirect
github.com/pierrec/lz4/v4 v4.1.18 // indirect
github.com/pierrec/lz4/v4 v4.1.18 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/prometheus/client_golang v1.12.1 // indirect
github.com/prometheus/client_model v0.2.0 // indirect
github.com/prometheus/common v0.34.0 // indirect
github.com/prometheus/procfs v0.7.3 // indirect
github.com/prometheus/prometheus v0.35.0 // indirect
github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect
github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect
github.com/redis/go-redis/v9 v9.5.1 // indirect
github.com/redis/go-redis/v9 v9.5.1 // indirect
github.com/rivo/uniseg v0.2.0 // indirect
github.com/rivo/uniseg v0.2.0 // indirect
github.com/rogpeppe/go-internal v1.12.0 // indirect
github.com/rogpeppe/go-internal v1.12.0 // indirect
github.com/samber/lo v1.38.1 // indirect
github.com/samber/slog-common v0.14.0 // indirect
github.com/samber/slog-fiber v1.11.2 // indirect
github.com/samber/slog-loki/v3 v3.2.1 // indirect
github.com/sirupsen/logrus v1.9.3 // indirect
github.com/sirupsen/logrus v1.9.3 // indirect
github.com/stretchr/testify v1.8.4 // indirect
github.com/valyala/bytebufferpool v1.0.0 // indirect
github.com/valyala/bytebufferpool v1.0.0 // indirect
github.com/valyala/fasthttp v1.51.0 // indirect
github.com/valyala/fasthttp v1.51.0 // indirect
github.com/valyala/tcplisten v1.0.0 // indirect
github.com/valyala/tcplisten v1.0.0 // indirect
go.opentelemetry.io/otel v1.19.0 // indirect
go.opentelemetry.io/otel/trace v1.19.0 // indirect
go.uber.org/atomic v1.9.0 // indirect
go.uber.org/goleak v1.2.1 // indirect
golang.org/x/crypto v0.17.0 // indirect
golang.org/x/crypto v0.17.0 // indirect
golang.org/x/exp v0.0.0-20231005195138-3e424a577f31 // indirect
golang.org/x/net v0.17.0 // indirect
golang.org/x/net v0.17.0 // indirect
golang.org/x/oauth2 v0.13.0 // indirect
golang.org/x/sys v0.16.0 // indirect
golang.org/x/sys v0.16.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/tools v0.14.0 // indirect
golang.org/x/tools v0.14.0 // indirect
google.golang.org/appengine v1.6.8 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20231002182017-d307bd883b97 // indirect
google.golang.org/grpc v1.60.1 // indirect
google.golang.org/protobuf v1.32.0 // indirect
google.golang.org/protobuf v1.32.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
)
go.sum
View file @
8bfc1b29
This source diff could not be displayed because it is too large. You can
view the blob
instead.
main.go
View file @
8bfc1b29
...
@@ -8,7 +8,6 @@ import (
...
@@ -8,7 +8,6 @@ import (
"log/slog"
"log/slog"
"net/http"
"net/http"
"net/url"
"net/url"
"os"
"strconv"
"strconv"
"strings"
"strings"
"sync"
"sync"
...
@@ -28,6 +27,9 @@ import (
...
@@ -28,6 +27,9 @@ import (
"github.com/gofiber/fiber/v2/middleware/recover"
"github.com/gofiber/fiber/v2/middleware/recover"
slogfiber
"github.com/samber/slog-fiber"
slogfiber
"github.com/samber/slog-fiber"
"github.com/grafana/loki-client-go/loki"
slogloki
"github.com/samber/slog-loki/v3"
)
)
var
(
var
(
...
@@ -471,7 +473,7 @@ var withBillDb bool
...
@@ -471,7 +473,7 @@ var withBillDb bool
func
main
()
{
func
main
()
{
var
questAddr
,
kafkaBroker
,
callbackAddrP
,
listenIpPort
,
aigcProduceTopic
,
aigcConsumerTopic
string
var
questAddr
,
kafkaBroker
,
callbackAddrP
,
listenIpPort
,
aigcProduceTopic
,
aigcConsumerTopic
,
logserver
string
var
redisAddr
,
redisPassWd
,
mysqlAddr
string
var
redisAddr
,
redisPassWd
,
mysqlAddr
string
var
mysqlPort
int
var
mysqlPort
int
...
@@ -494,6 +496,8 @@ func main() {
...
@@ -494,6 +496,8 @@ func main() {
flag
.
StringVar
(
&
mysqlUser
,
"mysqlUser"
,
"liuxuzhong"
,
"connect to mysql user"
)
flag
.
StringVar
(
&
mysqlUser
,
"mysqlUser"
,
"liuxuzhong"
,
"connect to mysql user"
)
flag
.
StringVar
(
&
mysqlPassWd
,
"mysqlPassWd"
,
"12345678"
,
"mysql user password"
)
flag
.
StringVar
(
&
mysqlPassWd
,
"mysqlPassWd"
,
"12345678"
,
"mysql user password"
)
flag
.
StringVar
(
&
logserver
,
"logserver"
,
"http://124.193.167.71:3100"
,
"LOKI log server"
)
flag
.
StringVar
(
&
callbackAddrP
,
"callbackIpAddr"
,
"localhost:6001"
,
"ip:port"
)
flag
.
StringVar
(
&
callbackAddrP
,
"callbackIpAddr"
,
"localhost:6001"
,
"ip:port"
)
flag
.
StringVar
(
&
listenIpPort
,
"listenIpPort"
,
"0.0.0.0:6001"
,
"api listen on ip:port"
)
flag
.
StringVar
(
&
listenIpPort
,
"listenIpPort"
,
"0.0.0.0:6001"
,
"api listen on ip:port"
)
flag
.
StringVar
(
&
aigcProduceTopic
,
"aigcProduceTopic"
,
"pbaigc"
,
"produce topic, default value is: pbaigc"
)
flag
.
StringVar
(
&
aigcProduceTopic
,
"aigcProduceTopic"
,
"pbaigc"
,
"produce topic, default value is: pbaigc"
)
...
@@ -510,10 +514,28 @@ func main() {
...
@@ -510,10 +514,28 @@ func main() {
slog
.
Info
(
"log level"
,
"level"
,
levelVar
.
String
())
slog
.
Info
(
"log level"
,
"level"
,
levelVar
.
String
())
slog
.
SetDefault
(
slog
.
New
(
slog
.
NewTextHandler
(
os
.
Stdout
,
&
slog
.
HandlerOptions
{
// slog.SetDefault(slog.New(slog.NewTextHandler(os.Stdout, &slog.HandlerOptions{
Level
:
levelVar
,
// Level: levelVar,
//AddSource: true,
// //AddSource: true,
})))
// })))
//"http://124.193.167.71:3100"
config
,
_
:=
loki
.
NewDefaultConfig
(
logserver
+
"/loki/api/v1/push"
)
config
.
TenantID
=
"api"
client
,
_
:=
loki
.
New
(
config
)
slog
.
SetDefault
(
slog
.
New
(
slogloki
.
Option
{
Level
:
levelVar
,
Client
:
client
}
.
NewLokiHandler
()))
//logger := slog.New(slogloki.Option{Level: slog.LevelDebug, Client: client}.NewLokiHandler())
// logger = logger.With("release", "v1.0.0")
// for i := 0; i < 10000; i++ {
// logger.Debug("debug log server", "i", i)
// slog.Debug("debug log server", "i", i)
// time.Sleep(time.Second)
// }
// logger.Error("A message")
defer
client
.
Stop
()
slog
.
Warn
(
"start param"
,
"quest"
,
slog
.
GroupValue
(
slog
.
String
(
"Addr"
,
questAddr
)))
slog
.
Warn
(
"start param"
,
"quest"
,
slog
.
GroupValue
(
slog
.
String
(
"Addr"
,
questAddr
)))
slog
.
Warn
(
"start param"
,
"kafka"
,
slog
.
GroupValue
(
slog
.
String
(
"Addr"
,
kafkaBroker
)),
slog
.
Group
(
"topic"
,
"aigcProduceTopic"
,
aigcProduceTopic
,
"aigcConsumerTopic"
,
aigcConsumerTopic
))
slog
.
Warn
(
"start param"
,
"kafka"
,
slog
.
GroupValue
(
slog
.
String
(
"Addr"
,
kafkaBroker
)),
slog
.
Group
(
"topic"
,
"aigcProduceTopic"
,
aigcProduceTopic
,
"aigcConsumerTopic"
,
aigcConsumerTopic
))
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment