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
2017526d
Commit
2017526d
authored
Feb 27, 2024
by
Your Name
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add service register
parent
dac0d0e0
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
82 additions
and
8 deletions
+82
-8
dockerfile
dockerfile
+3
-2
go.mod
go.mod
+6
-3
go.sum
go.sum
+6
-0
main.go
main.go
+18
-3
service-register.go
service-register.go
+49
-0
No files found.
dockerfile
View file @
2017526d
FROM
golang:1.21.
6
-alpine3.18 AS build
FROM
golang:1.21.
7
-alpine3.18 AS build
#FROM golang:1.20.6-alpine3.18 AS build
#FROM golang:1.21.3 AS base
#FROM golang:1.20.6-alpine3.18 AS build
...
...
@@ -11,8 +11,9 @@ ENV https_proxy 'http://192.168.1.180:1080'
RUN
mkdir
-p
./go-kafka/
COPY
./ ./go-kafka
COPY
./
payment ./payment
COPY
./
cache ./cache
COPY
./odysseus-protocol ./odysseus-protocol
COPY
./service-registry ./service-registry
#RUN pwd && ls && sleep 10
# RUN go mod tidy
...
...
go.mod
View file @
2017526d
...
...
@@ -6,6 +6,8 @@ replace github.com/odysseus/odysseus-protocol => ../odysseus-protocol
replace github.com/odysseus/cache => ../cache
replace github.com/odysseus/service-registry => ../service-registry
//replace github.com/odysseus/payment => ../payment
require (
...
...
@@ -53,19 +55,20 @@ require (
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.15 // indirect
github.com/odysseus/service-registry v0.0.0-00010101000000-000000000000 // indirect
github.com/pierrec/lz4/v4 v4.1.18 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect
github.com/redis/go-redis/v9 v9.
4.0
// indirect
github.com/redis/go-redis/v9 v9.
5.1
// indirect
github.com/rivo/uniseg v0.2.0 // indirect
github.com/rogpeppe/go-internal v1.12.0 // indirect
github.com/sirupsen/logrus v1.9.3 // indirect
github.com/valyala/bytebufferpool v1.0.0 // indirect
github.com/valyala/fasthttp v1.51.0 // indirect
github.com/valyala/tcplisten v1.0.0 // indirect
golang.org/x/crypto v0.1
4
.0 // indirect
golang.org/x/crypto v0.1
7
.0 // indirect
golang.org/x/net v0.17.0 // indirect
golang.org/x/sys v0.1
5
.0 // indirect
golang.org/x/sys v0.1
6
.0 // indirect
golang.org/x/tools v0.14.0 // indirect
google.golang.org/protobuf v1.32.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
...
...
go.sum
View file @
2017526d
...
...
@@ -245,6 +245,8 @@ github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 h1:N/ElC8H3+5X
github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4=
github.com/redis/go-redis/v9 v9.4.0 h1:Yzoz33UZw9I/mFhx4MNrB6Fk+XHO1VukNcCa1+lwyKk=
github.com/redis/go-redis/v9 v9.4.0/go.mod h1:hdY0cQFCN4fnSYT6TkisLufl/4W5UIXyv0b/CLO2V2M=
github.com/redis/go-redis/v9 v9.5.1 h1:H1X4D3yHPaYrkL5X06Wh6xNVM/pX0Ft4RV0vMGvLBh8=
github.com/redis/go-redis/v9 v9.5.1/go.mod h1:hdY0cQFCN4fnSYT6TkisLufl/4W5UIXyv0b/CLO2V2M=
github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY=
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU5NdKM8=
...
...
@@ -308,6 +310,8 @@ golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5y
golang.org/x/crypto v0.6.0/go.mod h1:OFC/31mSvZgRz0V1QTNCzfAI1aIRzbiufJtkMIlEp58=
golang.org/x/crypto v0.14.0 h1:wBqGXzWJW6m1XrIKlAH0Hs1JJ7+9KBwnIO8v66Q9cHc=
golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4=
golang.org/x/crypto v0.17.0 h1:r8bRNjWL3GshPW3gkd+RpvzWrZAwPS49OmTGZ/uhM4k=
golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4=
golang.org/x/exp v0.0.0-20231005195138-3e424a577f31 h1:9k5exFQKQglLo+RoP+4zMjOFE14P6+vyR0baDAi0Rcs=
golang.org/x/exp v0.0.0-20231005195138-3e424a577f31/go.mod h1:S2oDrQGGwySpoQPVqRShND87VCbxmc6bL1Yd2oYrm6k=
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
...
...
@@ -358,6 +362,8 @@ golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc=
golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.16.0 h1:xWw16ngr6ZMtmxDyKyIgsE93KNKz5HKmMa3b8ALHidU=
golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
...
...
main.go
View file @
2017526d
...
...
@@ -487,6 +487,8 @@ func main() {
slog
.
Warn
(
"start param"
,
"!!!!!!!!!!!!!!!!!!!!**********With Bill DB**********!!!!!!!!!!!!!!!!!!!!"
,
withBillDb
)
slog
.
Warn
(
"start param"
,
"!!!!!!!!!!!!!!!!!!!!**********With Bill DB**********!!!!!!!!!!!!!!!!!!!!"
,
withBillDb
)
go
Registry
(
redisAddr
,
redisPassWd
)
kafkaBrokers
=
[]
string
{
kafkaBroker
}
callbackAddr
=
callbackAddrP
...
...
@@ -543,6 +545,7 @@ func main() {
apiGroupV1
.
Post
(
"/*"
,
ApiAndJWT
)
jwtGroupV1
:=
jwtGroup
.
Group
(
"/v1"
)
jwtGroupV1
.
Post
(
"/*"
,
ApiAndJWT
)
callbackGroupV1
:=
callbackGroup
.
Group
(
"/v1"
)
...
...
@@ -581,10 +584,24 @@ func main() {
var
replanceQueryTask
*
model
.
TaskType
//var m = make([]byte, 1024*1024+1024*512)
//var m = make([]byte, 1024*1024+1024*512)
var
mypool
=
&
sync
.
Pool
{
New
:
func
()
interface
{}
{
mem
:=
make
([]
byte
,
1024
*
1024
+
1024
*
512
)
return
&
mem
},
}
func
ApiAndJWT
(
c
*
fiber
.
Ctx
)
error
{
slog
.
Debug
(
"ApiAndJWT"
,
"path"
,
c
.
Route
()
.
Path
)
//m := mypool.Get().(*[]byte)
//c, err := w.Write(*m)
//return c.Send(*m)
reqHeaders
:=
c
.
GetReqHeaders
()
//return c.SendString(reqHeaders["Task-Id"][0])
...
...
@@ -688,14 +705,12 @@ func ApiAndJWT(c *fiber.Ctx) error {
//fmt.Println("asyncMode-----------", asyncMode)
if
asyncMode
{
time
.
Sleep
(
10
*
time
.
Second
)
//
time.Sleep(10 * time.Second)
m
:=
make
([]
byte
,
1024
*
1024
+
1024
*
512
)
return
c
.
Send
(
m
)
//return c.SendString(pbMsg.TaskId)
}
else
{
return
syncModeF
(
c
,
pbMsg
.
TaskId
)
}
//fmt.Println("syncMode-------------", syncMode)
...
...
service-register.go
0 → 100644
View file @
2017526d
package
main
import
(
"encoding/json"
"time"
"github.com/odysseus/service-registry/common"
"github.com/odysseus/service-registry/query"
registry
"github.com/odysseus/service-registry/registry"
)
type
demoService
struct
{
}
func
(
d
demoService
)
ServiceType
()
common
.
ServiceType
{
return
common
.
SERVICE_API_GATEWAY
}
func
(
d
demoService
)
Endpoint
()
string
{
return
"http://service-endpoint_ai-api-magr:6001"
}
func
(
d
demoService
)
DetailInfo
()
(
json
.
RawMessage
,
error
)
{
//return nil, nil
detail
:=
struct
{
IP
string
`json:"ip"`
WorkerCount
int
`json:"worker_count"`
}{}
detail
.
IP
=
""
detail
.
WorkerCount
=
10
return
json
.
Marshal
(
detail
)
}
func
Registry
(
redisAddr
,
passWd
string
)
{
_
=
query
.
GatewayInfo
{
Endpoint
:
"http://query-endpoint_ai-api-magr:6001"
,
}
r
:=
registry
.
NewRegistry
(
registry
.
RedisConnParam
{
Addr
:
redisAddr
,
Password
:
passWd
,
DbIndex
:
0
,
},
demoService
{})
r
.
Start
()
time
.
Sleep
(
time
.
Second
*
5
)
r
.
Stop
()
}
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