Request.php
2.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
<?php
namespace AukeySwrpc\Request;
use AukeySwrpc\Tracer\TracerContext;
abstract class Request
{
protected string $module;
protected string $method;
protected array $params;
protected bool $isSync = true; //是否同步请求,默认是
protected bool $isSystem = false; //是否系统请求,默认否
protected $error;
protected ?TracerContext $traceContext;
public static function create($method, $params, ?TracerContext $traceContext = null)
{
return new static ($method, $params, $traceContext);
}
public function __construct($method, $params, ?TracerContext $traceContext = null)
{
$this->method = $method;
$this->params = $params;
$this->traceContext = $traceContext;
$this->init();
}
abstract public function init();
public function getModule(): string
{
return $this->module;
}
public function getMethod(): string
{
return $this->method;
}
public function getParams(): array
{
return $this->params;
}
public function setParams(array $params)
{
$this->params = $params;
}
public function setModule(string $name)
{
$this->module = $name;
}
public function mergeParams(array $params)
{
$this->params = array_merge($this->params, $params);
}
public function getTraceContext(): ?TracerContext
{
return $this->traceContext;
}
public function setTraceContext($traceID, $parentID, $url)
{
$this->traceContext = TracerContext::create($traceID, $parentID, $url);
}
public function setSync(bool $value)
{
$this->isSync = $value;
}
public function isSync(): bool
{
return $this->isSync;
}
public function setSystem(bool $value)
{
$this->isSystem = $value;
}
public function isSystem(): bool
{
return $this->isSystem;
}
public function getError()
{
return $this->error;
}
public function setError($err)
{
$this->error = $err;
}
}