1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Kaliop\Queueing\Plugins\SQSBundle\DependencyInjection; |
4
|
|
|
|
5
|
|
|
use Symfony\Component\Config\Definition\Builder\TreeBuilder; |
6
|
|
|
use Symfony\Component\Config\Definition\ConfigurationInterface; |
7
|
|
|
use \Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition; |
8
|
|
|
|
9
|
|
|
class Configuration implements ConfigurationInterface |
10
|
|
|
{ |
11
|
1 |
|
public function getConfigTreeBuilder() |
12
|
|
|
{ |
13
|
1 |
|
$tree = new TreeBuilder(); |
14
|
|
|
|
15
|
1 |
|
$rootNode = $tree->root('kaliop_queueing_plugins_sqs'); |
|
|
|
|
16
|
|
|
|
17
|
1 |
|
$this->addConnections($rootNode); |
18
|
1 |
|
$this->addQueues($rootNode); |
19
|
|
|
|
20
|
1 |
|
return $tree; |
21
|
|
|
} |
22
|
|
|
|
23
|
1 |
|
protected function addConnections(ArrayNodeDefinition $node) |
24
|
|
|
{ |
25
|
|
|
$node |
26
|
1 |
|
->fixXmlConfig('connection') |
27
|
1 |
|
->children() |
28
|
1 |
|
->arrayNode('connections') |
29
|
1 |
|
->useAttributeAsKey('key') |
30
|
1 |
|
->canBeUnset() |
31
|
1 |
|
->prototype('array') |
32
|
1 |
|
->children() |
33
|
1 |
|
->variableNode('credentials') |
34
|
|
|
//->children() |
35
|
|
|
//->whatever... |
36
|
|
|
//->end() |
37
|
1 |
|
->end() |
38
|
1 |
|
->scalarNode('region')->isRequired()->end() |
39
|
1 |
|
->scalarNode('version')->defaultValue('latest')->end() |
40
|
1 |
|
->booleanNode('debug')->defaultFalse()->end() |
41
|
1 |
|
->variableNode('http') |
42
|
|
|
//->children() |
43
|
|
|
//->whatever... |
44
|
|
|
//->end() |
45
|
1 |
|
->end() |
46
|
1 |
|
->end() |
47
|
1 |
|
->end() |
48
|
1 |
|
->end() |
49
|
1 |
|
->end() |
50
|
|
|
; |
51
|
1 |
|
} |
52
|
|
|
|
53
|
1 |
|
protected function addQueues(ArrayNodeDefinition $node) |
54
|
|
|
{ |
55
|
|
|
$node |
56
|
1 |
|
->fixXmlConfig('consumer') |
57
|
1 |
|
->children() |
58
|
1 |
|
->arrayNode('queues') |
59
|
1 |
|
->canBeUnset() |
60
|
1 |
|
->useAttributeAsKey('key') |
61
|
1 |
|
->prototype('array') |
62
|
1 |
|
->append($this->getQueueConfiguration()) |
63
|
1 |
|
->children() |
64
|
1 |
|
->scalarNode('connection')->defaultValue('default')->end() |
65
|
1 |
|
->scalarNode('callback')->isRequired()->end() // Q: could it be made optional? |
66
|
|
|
//->scalarNode('auto_setup_fabric')->defaultTrue()->end() |
67
|
1 |
|
->end() |
68
|
1 |
|
->end() |
69
|
1 |
|
->end() |
70
|
1 |
|
->end() |
71
|
|
|
; |
72
|
1 |
|
} |
73
|
|
|
|
74
|
1 |
|
protected function getQueueConfiguration() |
75
|
|
|
{ |
76
|
1 |
|
$node = new ArrayNodeDefinition('queue_options'); |
77
|
|
|
|
78
|
1 |
|
$this->addQueueNodeConfiguration($node); |
79
|
|
|
|
80
|
1 |
|
return $node; |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
/** |
84
|
|
|
* @todo we use an array for routing keys, as RabbitMQ config does, but we currently only support one |
85
|
|
|
* @param ArrayNodeDefinition $node |
86
|
|
|
*/ |
87
|
1 |
|
protected function addQueueNodeConfiguration(ArrayNodeDefinition $node) |
88
|
|
|
{ |
89
|
|
|
$node |
90
|
1 |
|
->children() |
91
|
1 |
|
->scalarNode('name')->end() |
92
|
1 |
|
->arrayNode('routing_keys') |
93
|
1 |
|
->prototype('scalar')->end() |
94
|
1 |
|
->defaultValue(array()) |
95
|
1 |
|
->end() |
96
|
1 |
|
->integerNode('max_messages_per_request')->min(1)->defaultValue(1)->end() |
97
|
1 |
|
->integerNode('request_timeout')->min(0)->defaultValue(0)->end() |
98
|
1 |
|
->integerNode('polling_interval')->min(0)->defaultValue(200000)->end() |
99
|
1 |
|
->integerNode('gc_probability')->min(0)->max(100)->defaultValue(1)->end() |
100
|
1 |
|
->scalarNode('message_group_id')->defaultValue(null)->end() |
101
|
1 |
|
->scalarNode('message_deduplication_id_calculator')->defaultValue(null)->end() |
102
|
1 |
|
->end() |
103
|
|
|
; |
104
|
1 |
|
} |
105
|
|
|
} |
106
|
|
|
|
This method has been deprecated. The supplier of the class has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.