summaryrefslogtreecommitdiff
path: root/vendor/packaged/thrift/src/Server/TServer.php
blob: 268c378209c00cae50b9460ab7468c5fbfc36e2a (plain)
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 Thrift\Server;

use Thrift\Factory\TTransportFactory;
use Thrift\Factory\TProtocolFactory;

/**
 * Generic class for a Thrift server.
 *
 * @package thrift.server
 */
abstract class TServer
{
    /**
     * Processor to handle new clients
     *
     * @var TProcessor
     */
    protected $processor_;

    /**
     * Server transport to be used for listening
     * and accepting new clients
     *
     * @var TServerTransport
     */
    protected $transport_;

    /**
     * Input transport factory
     *
     * @var TTransportFactory
     */
    protected $inputTransportFactory_;

    /**
     * Output transport factory
     *
     * @var TTransportFactory
     */
    protected $outputTransportFactory_;

    /**
     * Input protocol factory
     *
     * @var TProtocolFactory
     */
    protected $inputProtocolFactory_;

    /**
     * Output protocol factory
     *
     * @var TProtocolFactory
     */
    protected $outputProtocolFactory_;

    /**
     * Sets up all the factories, etc
     *
     * @param object $processor
     * @param TServerTransport $transport
     * @param TTransportFactory $inputTransportFactory
     * @param TTransportFactory $outputTransportFactory
     * @param TProtocolFactory $inputProtocolFactory
     * @param TProtocolFactory $outputProtocolFactory
     * @return void
     */
    public function __construct(
        $processor,
        TServerTransport $transport,
        TTransportFactory $inputTransportFactory,
        TTransportFactory $outputTransportFactory,
        TProtocolFactory $inputProtocolFactory,
        TProtocolFactory $outputProtocolFactory
    ) {
        $this->processor_ = $processor;
        $this->transport_ = $transport;
        $this->inputTransportFactory_ = $inputTransportFactory;
        $this->outputTransportFactory_ = $outputTransportFactory;
        $this->inputProtocolFactory_ = $inputProtocolFactory;
        $this->outputProtocolFactory_ = $outputProtocolFactory;
    }

    /**
     * Serves the server. This should never return
     * unless a problem permits it to do so or it
     * is interrupted intentionally
     *
     * @abstract
     * @return void
     */
    abstract public function serve();

    /**
     * Stops the server serving
     *
     * @abstract
     * @return void
     */
    abstract public function stop();
}