good morning!!!!
Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
J
jrpc
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Harbor Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
open
jrpc
Commits
fbcb603d
Commit
fbcb603d
authored
2 years ago
by
a
Browse files
Options
Downloads
Patches
Plain Diff
properly increase read limit
parent
d058ad78
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
websocket.go
+2
-2
2 additions, 2 deletions
websocket.go
wsjson/wsjson.go
+3
-4
3 additions, 4 deletions
wsjson/wsjson.go
with
5 additions
and
6 deletions
websocket.go
+
2
−
2
View file @
fbcb603d
...
@@ -34,7 +34,7 @@ const (
...
@@ -34,7 +34,7 @@ const (
wsPingInterval
=
60
*
time
.
Second
wsPingInterval
=
60
*
time
.
Second
wsPingWriteTimeout
=
5
*
time
.
Second
wsPingWriteTimeout
=
5
*
time
.
Second
wsPongTimeout
=
30
*
time
.
Second
wsPongTimeout
=
30
*
time
.
Second
wsMessageSizeLimit
=
32
*
1024
*
1024
wsMessageSizeLimit
=
128
*
1024
*
1024
)
)
// WebsocketHandler returns a handler that serves JSON-RPC to WebSocket connections.
// WebsocketHandler returns a handler that serves JSON-RPC to WebSocket connections.
...
@@ -154,11 +154,11 @@ func heartbeat(ctx context.Context, c *websocket.Conn, d time.Duration) {
...
@@ -154,11 +154,11 @@ func heartbeat(ctx context.Context, c *websocket.Conn, d time.Duration) {
}
}
func
newWebsocketCodec
(
ctx
context
.
Context
,
c
*
websocket
.
Conn
,
host
string
,
req
http
.
Header
)
ServerCodec
{
func
newWebsocketCodec
(
ctx
context
.
Context
,
c
*
websocket
.
Conn
,
host
string
,
req
http
.
Header
)
ServerCodec
{
c
.
SetReadLimit
(
wsMessageSizeLimit
)
jsonWriter
:=
func
(
v
any
)
error
{
jsonWriter
:=
func
(
v
any
)
error
{
return
wsjson
.
Write
(
context
.
Background
(),
c
,
v
)
return
wsjson
.
Write
(
context
.
Background
(),
c
,
v
)
}
}
jsonReader
:=
func
(
v
any
)
error
{
jsonReader
:=
func
(
v
any
)
error
{
c
.
SetReadLimit
(
wsMessageSizeLimit
)
return
wsjson
.
Read
(
context
.
Background
(),
c
,
v
)
return
wsjson
.
Read
(
context
.
Background
(),
c
,
v
)
}
}
conn
:=
websocket
.
NetConn
(
ctx
,
c
,
websocket
.
MessageText
)
conn
:=
websocket
.
NetConn
(
ctx
,
c
,
websocket
.
MessageText
)
...
...
This diff is collapsed.
Click to expand it.
wsjson/wsjson.go
+
3
−
4
View file @
fbcb603d
...
@@ -70,18 +70,17 @@ func Write(ctx context.Context, c *websocket.Conn, v interface{}) error {
...
@@ -70,18 +70,17 @@ func Write(ctx context.Context, c *websocket.Conn, v interface{}) error {
}
}
func
write
(
ctx
context
.
Context
,
c
*
websocket
.
Conn
,
v
interface
{})
(
err
error
)
{
func
write
(
ctx
context
.
Context
,
c
*
websocket
.
Conn
,
v
interface
{})
(
err
error
)
{
w
,
err
:=
c
.
Writer
(
ctx
,
websocket
.
MessageText
)
w
,
err
:=
c
.
Writer
(
ctx
,
websocket
.
MessageText
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
// json.Marshal cannot reuse buffers between calls as it has to return
// json.Marshal cannot reuse buffers between calls as it has to return
// a copy of the byte slice but Encoder does as it directly writes to w.
// a copy of the byte slice but Encoder does as it directly writes to w.
err
=
jzon
.
NewEncoder
(
w
)
.
Encode
(
v
)
st
:=
jsoniter
.
NewStream
(
jzon
,
w
,
1024
)
st
.
WriteVal
(
v
)
err
=
st
.
Flush
()
if
err
!=
nil
{
if
err
!=
nil
{
return
fmt
.
Errorf
(
"failed to marshal JSON: %w"
,
err
)
return
fmt
.
Errorf
(
"failed to marshal JSON: %w"
,
err
)
}
}
return
w
.
Close
()
return
w
.
Close
()
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment