-
Notifications
You must be signed in to change notification settings - Fork 1
/
NetworkInterface.php
113 lines (101 loc) · 2.7 KB
/
NetworkInterface.php
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
103
104
105
106
107
108
109
110
111
112
113
<?php
/*
* This file is part of the phpflo/phpflo package.
*
* (c) Marc Aschmann <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace PhpFlo\Common;
use PhpFlo\Core\Graph;
/**
* Interface NetworkInterface
*
* @package PhpFlo\Common
* @author Marc Aschmann <[email protected]>
*/
interface NetworkInterface extends HookableNetworkInterface
{
const SOURCE = 'from';
const TARGET = 'to';
const NODE_ID = 'id';
const COMPONENT = 'component';
const PROCESS = 'process';
const DATA = 'data';
const NODE = 'node';
const PORT = 'port';
const CONNECT = 'connect';
const DISCONNECT = 'disconnect';
const SHUTDOWN = 'shutdown';
const DETACH = 'detach';
const CONNECTION_SOURCE = 'src';
const CONNECTION_TARGET = 'tgt';
const EVENT_ADD = 'add.node';
const EVENT_REMOVE = 'remove.node';
const EVENT_ADD_EDGE = 'add.edge';
const EVENT_REMOVE_EDGE = 'remove.edge';
const BEGIN_GROUP = 'begin.group';
const END_GROUP = 'end.group';
/**
* @param array $edge
* @return NetworkInterface
* @throws InvalidDefinitionException
*/
public function addEdge(array $edge): NetworkInterface;
/**
* @param array $node
* @return NetworkInterface
* @throws InvalidDefinitionException
*/
public function addNode(array $node): NetworkInterface;
/**
* Add a flow definition as Graph object or definition file/string
* and initialize the network processes/connections
*
* @param mixed $graph
* @return NetworkInterface
* @throws InvalidDefinitionException
*/
public function boot($graph): NetworkInterface;
/**
* @return null|Graph
*/
public function getGraph();
/**
* @param string $id
* @return mixed|null
*/
public function getNode(string $id);
/**
* @param array $edge
* @return NetworkInterface
*/
public function removeEdge(array $edge): NetworkInterface;
/**
* @param array $node
* @return NetworkInterface
*/
public function removeNode(array $node): NetworkInterface;
/**
* Add initialization data
*
* @param mixed $data
* @param string $node
* @param string $port
* @return NetworkInterface
* @throws FlowException
*/
public function run($data, string $node, string $port): NetworkInterface;
/**
* Cleanup network state after runs.
*
* @return NetworkInterface
*/
public function shutdown(): NetworkInterface;
/**
* @return bool|\DateInterval
*/
public function uptime();
}