Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
thrift_33cn
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_33cn
Commits
1444fa75
Commit
1444fa75
authored
Apr 20, 2018
by
tufengqi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
init
parent
651920a2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
365 additions
and
1 deletion
+365
-1
Calculator.php
Thrift/gen-php/tutorial/Calculator.php
+261
-0
Types.php
Thrift/gen-php/tutorial/Types.php
+104
-1
No files found.
Thrift/gen-php/tutorial/Calculator.php
View file @
1444fa75
...
...
@@ -36,6 +36,11 @@ interface CalculatorIf extends \shared\SharedServiceIf {
*/
public
function
add
(
$num1
,
$num2
);
/**
* @param \tutorial\MemberInfoRequest[] $requests
* @return int
*/
public
function
addList
(
array
$requests
);
/**
* @param int $logid
* @param \tutorial\Work $w
* @return int
...
...
@@ -156,6 +161,57 @@ class CalculatorClient extends \shared\SharedServiceClient implements \tutorial\
throw
new
\Exception
(
"add failed: unknown result"
);
}
public
function
addList
(
array
$requests
)
{
$this
->
send_addList
(
$requests
);
return
$this
->
recv_addList
();
}
public
function
send_addList
(
array
$requests
)
{
$args
=
new
\tutorial\Calculator_addList_args
();
$args
->
requests
=
$requests
;
$bin_accel
=
(
$this
->
output_
instanceof
TBinaryProtocolAccelerated
)
&&
function_exists
(
'thrift_protocol_write_binary'
);
if
(
$bin_accel
)
{
thrift_protocol_write_binary
(
$this
->
output_
,
'addList'
,
TMessageType
::
CALL
,
$args
,
$this
->
seqid_
,
$this
->
output_
->
isStrictWrite
());
}
else
{
$this
->
output_
->
writeMessageBegin
(
'addList'
,
TMessageType
::
CALL
,
$this
->
seqid_
);
$args
->
write
(
$this
->
output_
);
$this
->
output_
->
writeMessageEnd
();
$this
->
output_
->
getTransport
()
->
flush
();
}
}
public
function
recv_addList
()
{
$bin_accel
=
(
$this
->
input_
instanceof
TBinaryProtocolAccelerated
)
&&
function_exists
(
'thrift_protocol_read_binary'
);
if
(
$bin_accel
)
$result
=
thrift_protocol_read_binary
(
$this
->
input_
,
'\tutorial\Calculator_addList_result'
,
$this
->
input_
->
isStrictRead
());
else
{
$rseqid
=
0
;
$fname
=
null
;
$mtype
=
0
;
$this
->
input_
->
readMessageBegin
(
$fname
,
$mtype
,
$rseqid
);
if
(
$mtype
==
TMessageType
::
EXCEPTION
)
{
$x
=
new
TApplicationException
();
$x
->
read
(
$this
->
input_
);
$this
->
input_
->
readMessageEnd
();
throw
$x
;
}
$result
=
new
\tutorial\Calculator_addList_result
();
$result
->
read
(
$this
->
input_
);
$this
->
input_
->
readMessageEnd
();
}
if
(
$result
->
success
!==
null
)
{
return
$result
->
success
;
}
throw
new
\Exception
(
"addList failed: unknown result"
);
}
public
function
calculate
(
$logid
,
\tutorial\Work
$w
)
{
$this
->
send_calculate
(
$logid
,
$w
);
...
...
@@ -509,6 +565,184 @@ class Calculator_add_result {
}
class
Calculator_addList_args
{
static
$isValidate
=
false
;
static
$_TSPEC
=
array
(
1
=>
array
(
'var'
=>
'requests'
,
'isRequired'
=>
false
,
'type'
=>
TType
::
LST
,
'etype'
=>
TType
::
STRUCT
,
'elem'
=>
array
(
'type'
=>
TType
::
STRUCT
,
'class'
=>
'\tutorial\MemberInfoRequest'
,
),
),
);
/**
* @var \tutorial\MemberInfoRequest[]
*/
public
$requests
=
null
;
public
function
__construct
(
$vals
=
null
)
{
if
(
is_array
(
$vals
))
{
if
(
isset
(
$vals
[
'requests'
]))
{
$this
->
requests
=
$vals
[
'requests'
];
}
}
}
public
function
getName
()
{
return
'Calculator_addList_args'
;
}
public
function
read
(
$input
)
{
$xfer
=
0
;
$fname
=
null
;
$ftype
=
0
;
$fid
=
0
;
$xfer
+=
$input
->
readStructBegin
(
$fname
);
while
(
true
)
{
$xfer
+=
$input
->
readFieldBegin
(
$fname
,
$ftype
,
$fid
);
if
(
$ftype
==
TType
::
STOP
)
{
break
;
}
switch
(
$fid
)
{
case
1
:
if
(
$ftype
==
TType
::
LST
)
{
$this
->
requests
=
array
();
$_size0
=
0
;
$_etype3
=
0
;
$xfer
+=
$input
->
readListBegin
(
$_etype3
,
$_size0
);
for
(
$_i4
=
0
;
$_i4
<
$_size0
;
++
$_i4
)
{
$elem5
=
null
;
$elem5
=
new
\tutorial\MemberInfoRequest
();
$xfer
+=
$elem5
->
read
(
$input
);
$this
->
requests
[]
=
$elem5
;
}
$xfer
+=
$input
->
readListEnd
();
}
else
{
$xfer
+=
$input
->
skip
(
$ftype
);
}
break
;
default
:
$xfer
+=
$input
->
skip
(
$ftype
);
break
;
}
$xfer
+=
$input
->
readFieldEnd
();
}
$xfer
+=
$input
->
readStructEnd
();
return
$xfer
;
}
public
function
write
(
$output
)
{
$xfer
=
0
;
$xfer
+=
$output
->
writeStructBegin
(
'Calculator_addList_args'
);
if
(
$this
->
requests
!==
null
)
{
if
(
!
is_array
(
$this
->
requests
))
{
throw
new
TProtocolException
(
'Bad type in structure.'
,
TProtocolException
::
INVALID_DATA
);
}
$xfer
+=
$output
->
writeFieldBegin
(
'requests'
,
TType
::
LST
,
1
);
{
$output
->
writeListBegin
(
TType
::
STRUCT
,
count
(
$this
->
requests
));
{
foreach
(
$this
->
requests
as
$iter6
)
{
$xfer
+=
$iter6
->
write
(
$output
);
}
}
$output
->
writeListEnd
();
}
$xfer
+=
$output
->
writeFieldEnd
();
}
$xfer
+=
$output
->
writeFieldStop
();
$xfer
+=
$output
->
writeStructEnd
();
return
$xfer
;
}
}
class
Calculator_addList_result
{
static
$isValidate
=
false
;
static
$_TSPEC
=
array
(
0
=>
array
(
'var'
=>
'success'
,
'isRequired'
=>
false
,
'type'
=>
TType
::
I32
,
),
);
/**
* @var int
*/
public
$success
=
null
;
public
function
__construct
(
$vals
=
null
)
{
if
(
is_array
(
$vals
))
{
if
(
isset
(
$vals
[
'success'
]))
{
$this
->
success
=
$vals
[
'success'
];
}
}
}
public
function
getName
()
{
return
'Calculator_addList_result'
;
}
public
function
read
(
$input
)
{
$xfer
=
0
;
$fname
=
null
;
$ftype
=
0
;
$fid
=
0
;
$xfer
+=
$input
->
readStructBegin
(
$fname
);
while
(
true
)
{
$xfer
+=
$input
->
readFieldBegin
(
$fname
,
$ftype
,
$fid
);
if
(
$ftype
==
TType
::
STOP
)
{
break
;
}
switch
(
$fid
)
{
case
0
:
if
(
$ftype
==
TType
::
I32
)
{
$xfer
+=
$input
->
readI32
(
$this
->
success
);
}
else
{
$xfer
+=
$input
->
skip
(
$ftype
);
}
break
;
default
:
$xfer
+=
$input
->
skip
(
$ftype
);
break
;
}
$xfer
+=
$input
->
readFieldEnd
();
}
$xfer
+=
$input
->
readStructEnd
();
return
$xfer
;
}
public
function
write
(
$output
)
{
$xfer
=
0
;
$xfer
+=
$output
->
writeStructBegin
(
'Calculator_addList_result'
);
if
(
$this
->
success
!==
null
)
{
$xfer
+=
$output
->
writeFieldBegin
(
'success'
,
TType
::
I32
,
0
);
$xfer
+=
$output
->
writeI32
(
$this
->
success
);
$xfer
+=
$output
->
writeFieldEnd
();
}
$xfer
+=
$output
->
writeFieldStop
();
$xfer
+=
$output
->
writeStructEnd
();
return
$xfer
;
}
}
class
Calculator_calculate_args
{
static
$isValidate
=
false
;
...
...
@@ -843,6 +1077,33 @@ class CalculatorProcessor extends \shared\SharedServiceProcessor {
$output
->
getTransport
()
->
flush
();
}
}
protected
function
process_addList
(
$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_addList_args'
,
$input
->
isStrictRead
());
}
else
{
$args
=
new
\tutorial\Calculator_addList_args
();
$args
->
read
(
$input
);
$input
->
readMessageEnd
();
}
$result
=
new
\tutorial\Calculator_addList_result
();
$result
->
success
=
$this
->
handler_
->
addList
(
$args
->
requests
);
$bin_accel
=
(
$output
instanceof
TBinaryProtocolAccelerated
)
&&
function_exists
(
'thrift_protocol_write_binary'
);
if
(
$bin_accel
)
{
thrift_protocol_write_binary
(
$output
,
'addList'
,
TMessageType
::
REPLY
,
$result
,
$seqid
,
$output
->
isStrictWrite
());
}
else
{
$output
->
writeMessageBegin
(
'addList'
,
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
)
...
...
Thrift/gen-php/tutorial/Types.php
View file @
1444fa75
...
...
@@ -292,6 +292,109 @@ class InvalidOperation extends TException {
}
class
MemberInfoRequest
{
static
$isValidate
=
false
;
static
$_TSPEC
=
array
(
1
=>
array
(
'var'
=>
'type_id'
,
'isRequired'
=>
false
,
'type'
=>
TType
::
I16
,
),
2
=>
array
(
'var'
=>
'id'
,
'isRequired'
=>
false
,
'type'
=>
TType
::
I64
,
),
);
/**
* 用户类型
*
* @var int
*/
public
$type_id
=
null
;
/**
* 用户ID
*
* @var int
*/
public
$id
=
null
;
public
function
__construct
(
$vals
=
null
)
{
if
(
is_array
(
$vals
))
{
if
(
isset
(
$vals
[
'type_id'
]))
{
$this
->
type_id
=
$vals
[
'type_id'
];
}
if
(
isset
(
$vals
[
'id'
]))
{
$this
->
id
=
$vals
[
'id'
];
}
}
}
public
function
getName
()
{
return
'MemberInfoRequest'
;
}
public
function
read
(
$input
)
{
$xfer
=
0
;
$fname
=
null
;
$ftype
=
0
;
$fid
=
0
;
$xfer
+=
$input
->
readStructBegin
(
$fname
);
while
(
true
)
{
$xfer
+=
$input
->
readFieldBegin
(
$fname
,
$ftype
,
$fid
);
if
(
$ftype
==
TType
::
STOP
)
{
break
;
}
switch
(
$fid
)
{
case
1
:
if
(
$ftype
==
TType
::
I16
)
{
$xfer
+=
$input
->
readI16
(
$this
->
type_id
);
}
else
{
$xfer
+=
$input
->
skip
(
$ftype
);
}
break
;
case
2
:
if
(
$ftype
==
TType
::
I64
)
{
$xfer
+=
$input
->
readI64
(
$this
->
id
);
}
else
{
$xfer
+=
$input
->
skip
(
$ftype
);
}
break
;
default
:
$xfer
+=
$input
->
skip
(
$ftype
);
break
;
}
$xfer
+=
$input
->
readFieldEnd
();
}
$xfer
+=
$input
->
readStructEnd
();
return
$xfer
;
}
public
function
write
(
$output
)
{
$xfer
=
0
;
$xfer
+=
$output
->
writeStructBegin
(
'MemberInfoRequest'
);
if
(
$this
->
type_id
!==
null
)
{
$xfer
+=
$output
->
writeFieldBegin
(
'type_id'
,
TType
::
I16
,
1
);
$xfer
+=
$output
->
writeI16
(
$this
->
type_id
);
$xfer
+=
$output
->
writeFieldEnd
();
}
if
(
$this
->
id
!==
null
)
{
$xfer
+=
$output
->
writeFieldBegin
(
'id'
,
TType
::
I64
,
2
);
$xfer
+=
$output
->
writeI64
(
$this
->
id
);
$xfer
+=
$output
->
writeFieldEnd
();
}
$xfer
+=
$output
->
writeFieldStop
();
$xfer
+=
$output
->
writeStructEnd
();
return
$xfer
;
}
}
final
class
Constant
extends
\Thrift\Type\TConstant
{
static
protected
$INT32CONSTANT
;
static
protected
$MAPCONSTANT
;
...
...
@@ -301,7 +404,7 @@ final class Constant extends \Thrift\Type\TConstant {
* Thrift also lets you define constants for use across languages. Complex
* types and structs are specified using JSON notation.
*/
9853
;
9853
;
}
static
protected
function
init_MAPCONSTANT
()
{
...
...
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