Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
G
getty
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
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
wei.xuan
getty
Commits
cbb16389
Unverified
Commit
cbb16389
authored
Jul 06, 2018
by
Xin.Zh
Committed by
GitHub
Jul 06, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #5 from hudangwei/master
LGTM
parents
388d0a67
f8bedfec
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
4 deletions
+6
-4
codec.go
rpc/codec.go
+5
-4
client.go
rpc/example/client/client.go
+1
-0
No files found.
rpc/codec.go
View file @
cbb16389
...
...
@@ -135,8 +135,9 @@ func (c PBCodec) Decode(data []byte, i interface{}) error {
////////////////////////////////////////////
const
(
gettyPackageMagic
=
0x20160905
maxPackageLen
=
1024
*
1024
gettyPackageMagic
=
0x20160905
maxPackageLen
=
1024
*
1024
rpcPackagePlaceholderLen
=
2
)
var
(
...
...
@@ -220,7 +221,7 @@ func (p *GettyPackage) Marshal() (*bytes.Buffer, error) {
func
(
p
*
GettyPackage
)
Unmarshal
(
buf
*
bytes
.
Buffer
)
(
int
,
error
)
{
var
err
error
if
buf
.
Len
()
<
2
+
gettyPackageHeaderLen
{
if
buf
.
Len
()
<
rpcPackagePlaceholderLen
+
gettyPackageHeaderLen
{
return
0
,
ErrNotEnoughStream
}
var
packLen
uint16
...
...
@@ -244,7 +245,7 @@ func (p *GettyPackage) Unmarshal(buf *bytes.Buffer) (int, error) {
return
0
,
ErrIllegalMagic
}
if
int
(
packLen
)
>
gettyPackageHeaderLen
{
if
int
(
packLen
)
>
rpcPackagePlaceholderLen
+
gettyPackageHeaderLen
{
if
err
:=
p
.
B
.
Unmarshal
(
p
.
H
.
CodecType
,
bytes
.
NewBuffer
(
buf
.
Next
(
int
(
packLen
)
-
gettyPackageHeaderLen
)));
err
!=
nil
{
return
0
,
jerrors
.
Trace
(
err
)
}
...
...
rpc/example/client/client.go
View file @
cbb16389
...
...
@@ -11,6 +11,7 @@ import (
func
main
()
{
log
.
LoadConfiguration
(
"client_log.xml"
)
client
:=
rpc
.
NewClient
(
"client_config.toml"
)
// client.SetCodecType(rpc.ProtoBuffer)//默认是json序列化
defer
client
.
Close
()
for
i
:=
0
;
i
<
100
;
i
++
{
...
...
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