Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
thrift
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
tufengqi
thrift
Commits
d0292637
Commit
d0292637
authored
Apr 19, 2018
by
tufengqi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
init
parent
1898936e
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
182 additions
and
0 deletions
+182
-0
SharedService.php
tutorial/gen-php/shared/SharedService.php
+55
-0
Calculator.php
tutorial/gen-php/tutorial/Calculator.php
+127
-0
No files found.
tutorial/gen-php/shared/SharedService.php
View file @
d0292637
...
...
@@ -247,4 +247,59 @@ class SharedService_getStruct_result {
}
class
SharedServiceProcessor
{
protected
$handler_
=
null
;
public
function
__construct
(
$handler
)
{
$this
->
handler_
=
$handler
;
}
public
function
process
(
$input
,
$output
)
{
$rseqid
=
0
;
$fname
=
null
;
$mtype
=
0
;
$input
->
readMessageBegin
(
$fname
,
$mtype
,
$rseqid
);
$methodname
=
'process_'
.
$fname
;
if
(
!
method_exists
(
$this
,
$methodname
))
{
$input
->
skip
(
TType
::
STRUCT
);
$input
->
readMessageEnd
();
$x
=
new
TApplicationException
(
'Function '
.
$fname
.
' not implemented.'
,
TApplicationException
::
UNKNOWN_METHOD
);
$output
->
writeMessageBegin
(
$fname
,
TMessageType
::
EXCEPTION
,
$rseqid
);
$x
->
write
(
$output
);
$output
->
writeMessageEnd
();
$output
->
getTransport
()
->
flush
();
return
;
}
$this
->
$methodname
(
$rseqid
,
$input
,
$output
);
return
true
;
}
protected
function
process_getStruct
(
$seqid
,
$input
,
$output
)
{
$bin_accel
=
(
$input
instanceof
TBinaryProtocolAccelerated
)
&&
function_exists
(
'thrift_protocol_read_binary_after_message_begin'
);
if
(
$bin_accel
)
{
$args
=
thrift_protocol_read_binary_after_message_begin
(
$input
,
'\shared\SharedService_getStruct_args'
,
$input
->
isStrictRead
());
}
else
{
$args
=
new
\shared\SharedService_getStruct_args
();
$args
->
read
(
$input
);
$input
->
readMessageEnd
();
}
$result
=
new
\shared\SharedService_getStruct_result
();
$result
->
success
=
$this
->
handler_
->
getStruct
(
$args
->
key
);
$bin_accel
=
(
$output
instanceof
TBinaryProtocolAccelerated
)
&&
function_exists
(
'thrift_protocol_write_binary'
);
if
(
$bin_accel
)
{
thrift_protocol_write_binary
(
$output
,
'getStruct'
,
TMessageType
::
REPLY
,
$result
,
$seqid
,
$output
->
isStrictWrite
());
}
else
{
$output
->
writeMessageBegin
(
'getStruct'
,
TMessageType
::
REPLY
,
$seqid
);
$result
->
write
(
$output
);
$output
->
writeMessageEnd
();
$output
->
getTransport
()
->
flush
();
}
}
}
tutorial/gen-php/tutorial/Calculator.php
View file @
d0292637
...
...
@@ -763,4 +763,131 @@ class Calculator_zip_args {
}
class
CalculatorProcessor
extends
\shared\SharedServiceProcessor
{
public
function
__construct
(
$handler
)
{
parent
::
__construct
(
$handler
);
}
public
function
process
(
$input
,
$output
)
{
$rseqid
=
0
;
$fname
=
null
;
$mtype
=
0
;
$input
->
readMessageBegin
(
$fname
,
$mtype
,
$rseqid
);
$methodname
=
'process_'
.
$fname
;
if
(
!
method_exists
(
$this
,
$methodname
))
{
$input
->
skip
(
TType
::
STRUCT
);
$input
->
readMessageEnd
();
$x
=
new
TApplicationException
(
'Function '
.
$fname
.
' not implemented.'
,
TApplicationException
::
UNKNOWN_METHOD
);
$output
->
writeMessageBegin
(
$fname
,
TMessageType
::
EXCEPTION
,
$rseqid
);
$x
->
write
(
$output
);
$output
->
writeMessageEnd
();
$output
->
getTransport
()
->
flush
();
return
;
}
$this
->
$methodname
(
$rseqid
,
$input
,
$output
);
return
true
;
}
protected
function
process_ping
(
$seqid
,
$input
,
$output
)
{
$bin_accel
=
(
$input
instanceof
TBinaryProtocolAccelerated
)
&&
function_exists
(
'thrift_protocol_read_binary_after_message_begin'
);
if
(
$bin_accel
)
{
$args
=
thrift_protocol_read_binary_after_message_begin
(
$input
,
'\tutorial\Calculator_ping_args'
,
$input
->
isStrictRead
());
}
else
{
$args
=
new
\tutorial\Calculator_ping_args
();
$args
->
read
(
$input
);
$input
->
readMessageEnd
();
}
$result
=
new
\tutorial\Calculator_ping_result
();
$this
->
handler_
->
ping
();
$bin_accel
=
(
$output
instanceof
TBinaryProtocolAccelerated
)
&&
function_exists
(
'thrift_protocol_write_binary'
);
if
(
$bin_accel
)
{
thrift_protocol_write_binary
(
$output
,
'ping'
,
TMessageType
::
REPLY
,
$result
,
$seqid
,
$output
->
isStrictWrite
());
}
else
{
$output
->
writeMessageBegin
(
'ping'
,
TMessageType
::
REPLY
,
$seqid
);
$result
->
write
(
$output
);
$output
->
writeMessageEnd
();
$output
->
getTransport
()
->
flush
();
}
}
protected
function
process_add
(
$seqid
,
$input
,
$output
)
{
$bin_accel
=
(
$input
instanceof
TBinaryProtocolAccelerated
)
&&
function_exists
(
'thrift_protocol_read_binary_after_message_begin'
);
if
(
$bin_accel
)
{
$args
=
thrift_protocol_read_binary_after_message_begin
(
$input
,
'\tutorial\Calculator_add_args'
,
$input
->
isStrictRead
());
}
else
{
$args
=
new
\tutorial\Calculator_add_args
();
$args
->
read
(
$input
);
$input
->
readMessageEnd
();
}
$result
=
new
\tutorial\Calculator_add_result
();
$result
->
success
=
$this
->
handler_
->
add
(
$args
->
num1
,
$args
->
num2
);
$bin_accel
=
(
$output
instanceof
TBinaryProtocolAccelerated
)
&&
function_exists
(
'thrift_protocol_write_binary'
);
if
(
$bin_accel
)
{
thrift_protocol_write_binary
(
$output
,
'add'
,
TMessageType
::
REPLY
,
$result
,
$seqid
,
$output
->
isStrictWrite
());
}
else
{
$output
->
writeMessageBegin
(
'add'
,
TMessageType
::
REPLY
,
$seqid
);
$result
->
write
(
$output
);
$output
->
writeMessageEnd
();
$output
->
getTransport
()
->
flush
();
}
}
protected
function
process_calculate
(
$seqid
,
$input
,
$output
)
{
$bin_accel
=
(
$input
instanceof
TBinaryProtocolAccelerated
)
&&
function_exists
(
'thrift_protocol_read_binary_after_message_begin'
);
if
(
$bin_accel
)
{
$args
=
thrift_protocol_read_binary_after_message_begin
(
$input
,
'\tutorial\Calculator_calculate_args'
,
$input
->
isStrictRead
());
}
else
{
$args
=
new
\tutorial\Calculator_calculate_args
();
$args
->
read
(
$input
);
$input
->
readMessageEnd
();
}
$result
=
new
\tutorial\Calculator_calculate_result
();
try
{
$result
->
success
=
$this
->
handler_
->
calculate
(
$args
->
logid
,
$args
->
w
);
}
catch
(
\tutorial\InvalidOperation
$ouch
)
{
$result
->
ouch
=
$ouch
;
}
$bin_accel
=
(
$output
instanceof
TBinaryProtocolAccelerated
)
&&
function_exists
(
'thrift_protocol_write_binary'
);
if
(
$bin_accel
)
{
thrift_protocol_write_binary
(
$output
,
'calculate'
,
TMessageType
::
REPLY
,
$result
,
$seqid
,
$output
->
isStrictWrite
());
}
else
{
$output
->
writeMessageBegin
(
'calculate'
,
TMessageType
::
REPLY
,
$seqid
);
$result
->
write
(
$output
);
$output
->
writeMessageEnd
();
$output
->
getTransport
()
->
flush
();
}
}
protected
function
process_zip
(
$seqid
,
$input
,
$output
)
{
$bin_accel
=
(
$input
instanceof
TBinaryProtocolAccelerated
)
&&
function_exists
(
'thrift_protocol_read_binary_after_message_begin'
);
if
(
$bin_accel
)
{
$args
=
thrift_protocol_read_binary_after_message_begin
(
$input
,
'\tutorial\Calculator_zip_args'
,
$input
->
isStrictRead
());
}
else
{
$args
=
new
\tutorial\Calculator_zip_args
();
$args
->
read
(
$input
);
$input
->
readMessageEnd
();
}
$this
->
handler_
->
zip
();
return
;
}
}
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