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
5a71daf7
Commit
5a71daf7
authored
Mar 12, 2024
by
Cloud User
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
http api expires
parent
046f8f6a
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
8 deletions
+19
-8
callback.go
callback.go
+19
-8
No files found.
callback.go
View file @
5a71daf7
...
...
@@ -2,8 +2,11 @@ package main
import
(
"sync"
"time"
pbUpstream
"github.com/odysseus/odysseus-protocol/gen/proto/go/base/v1"
"github.com/hashicorp/golang-lru/v2/expirable"
)
type
apiQueryTxsForAddr
struct
{
...
...
@@ -47,7 +50,8 @@ func callbackRes(res pbUpstream.TaskResponse) {
if
!
resAsV
.
async
{
resAsV
.
res
<-
res
}
else
{
asyncmap
.
Store
(
res
.
TaskId
,
res
)
asyncmap
.
Add
(
res
.
TaskId
,
res
)
//asyncmap.Store(res.TaskId, res)
}
}
}
...
...
@@ -55,18 +59,25 @@ func callbackRes(res pbUpstream.TaskResponse) {
func
getAsyncRes
(
uuid
string
)
(
pbUpstream
.
TaskResponse
,
bool
)
{
if
v
,
ok
:=
asyncmap
.
LoadAndDelete
(
uuid
);
ok
{
if
resAsV
,
ok
:=
v
.
(
pbUpstream
.
TaskResponse
);
ok
{
return
resAsV
,
true
}
}
return
asyncmap
.
Get
(
uuid
)
// if v, ok := asyncmap.LoadAndDelete(uuid); ok {
// if resAsV, ok := v.(pbUpstream.TaskResponse); ok {
// return resAsV, true
// }
// }
return
pbUpstream
.
TaskResponse
{},
false
//
return pbUpstream.TaskResponse{}, false
}
var
recordmap
sync
.
Map
var
asyncmap
sync
.
Map
var
asyncmap
*
expirable
.
LRU
[
string
,
pbUpstream
.
TaskResponse
]
func
init
()
{
asyncmap
=
expirable
.
NewLRU
[
string
,
pbUpstream
.
TaskResponse
](
10000
,
nil
,
time
.
Hour
*
1
)
}
func
recordUUID
()
{
for
message
:=
range
ApiQueryTxsByAddrForQueue
{
...
...
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