Skip to content

Commit 9ebf49f

Browse files
committed
Tweak config
1 parent 32325bd commit 9ebf49f

File tree

2 files changed

+105
-104
lines changed

2 files changed

+105
-104
lines changed

docs/ConfigurationReference.md

Lines changed: 81 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -2,67 +2,85 @@
22

33
```yaml
44
gos_web_socket:
5-
client:
6-
session_handler: ~ # Example: @session.handler.pdo
7-
firewall: ws_firewall # Example: secured_area
8-
storage:
9-
driver: gos_web_socket.client.driver.in_memory # Example: gos_web_socket.client.driver.in_memory
10-
ttl: 900 # Example: 3600
11-
prefix: '' # Deprecated (The "prefix" node is deprecated and will be removed in GosWebSocketBundle 4.0.), Example: client
12-
decorator: ~
13-
shared_config: true
14-
server:
15-
host: ~ # Required, Example: 127.0.0.1
16-
port: ~ # Required, Example: 8080
17-
origin_check: false # Example: true
18-
19-
# Flag indicating a keepalive ping should be enabled on the server
20-
keepalive_ping: false # Example: true
21-
22-
# The time in seconds between each keepalive ping
23-
keepalive_interval: 30 # Example: 30
24-
router:
25-
resources:
26-
27-
# Prototype
28-
-
29-
resource: ~ # Required
30-
type: null # One of "closure"; "container"; "glob"; "php"; "xml"; "yaml"; null
31-
origins: []
32-
ping:
33-
services:
34-
35-
# Prototype
36-
-
37-
38-
# The name of the service to ping
39-
name: ~ # Required
40-
41-
# The type of the service to be pinged; valid options are "doctrine" and "pdo"
42-
type: ~ # One of "doctrine"; "pdo", Required
43-
websocket_client: # Deprecated (The "websocket_client" node is deprecated and will be removed in GosWebSocketBundle 4.0. Use the ratchet/pawl package instead.)
44-
enabled: false
45-
host: ~ # Required, Example: 127.0.0.1
46-
port: ~ # Required, Example: 1337
47-
ssl: false
48-
origin: null
49-
pushers: # Deprecated (The "pushers" node is deprecated and will be removed in GosWebSocketBundle 4.0. Use the symfony/messenger component instead.)
50-
amqp: # Deprecated (The "amqp" node is deprecated and will be removed in GosWebSocketBundle 4.0. Use the symfony/messenger component instead.)
51-
enabled: false
52-
host: ~ # Required, Example: 127.0.0.1
53-
port: ~ # Required, Example: 5672
54-
login: ~ # Required
55-
password: ~ # Required
56-
vhost: /
57-
read_timeout: 0
58-
write_timeout: 0
59-
connect_timeout: 0
60-
queue_name: gos_websocket
61-
exchange_name: gos_websocket_exchange
62-
wamp: # Deprecated (The "wamp" node is deprecated and will be removed in GosWebSocketBundle 4.0. Use the symfony/messenger component instead.)
63-
enabled: false
64-
host: ~ # Required, Example: 127.0.0.1
65-
port: ~ # Required, Example: 1337
66-
ssl: false
67-
origin: null
5+
client:
6+
7+
# The service ID of the session handler service used to read session data.
8+
session_handler: ~
9+
10+
# The name of the security firewall to load the authenticated user data for.
11+
firewall: ws_firewall
12+
storage:
13+
14+
# The service ID of the storage driver to use for storing connection data.
15+
driver: gos_web_socket.client.driver.in_memory
16+
17+
# The cache TTL (in seconds) for clients in storage.
18+
ttl: 900
19+
prefix: '' # Deprecated (Since gos/web-socket-bundle 3.1: The "prefix" node is deprecated and will be removed in GosWebSocketBundle 4.0.)
20+
21+
# The service ID of a decorator for the client storage driver.
22+
decorator: ~
23+
shared_config: true
24+
server:
25+
26+
# The host IP address on the server which connections for the websocket server are accepted.
27+
host: ~ # Required
28+
29+
# The port on the server which connections for the websocket server are accepted.
30+
port: ~ # Required
31+
32+
# Enables checking the Origin header of websocket connections for allowed values.
33+
origin_check: false
34+
35+
# Flag indicating a keepalive ping should be enabled on the server.
36+
keepalive_ping: false
37+
38+
# The time in seconds between each keepalive ping.
39+
keepalive_interval: 30
40+
router:
41+
resources:
42+
43+
# Prototype
44+
-
45+
resource: ~ # Required
46+
type: null # One of "closure"; "container"; "glob"; "php"; "xml"; "yaml"; null
47+
48+
# A list of origins allowed to connect to the websocket server, must match the value from the "Origin" header of the HTTP request.
49+
origins: []
50+
ping:
51+
services:
52+
53+
# Prototype
54+
-
55+
56+
# The name of the service to ping.
57+
name: ~ # Required
58+
59+
# The type of the service to be pinged.
60+
type: ~ # One of "doctrine"; "pdo", Required
61+
websocket_client: # Deprecated (Since gos/web-socket-bundle 3.4: The "websocket_client" node is deprecated and will be removed in GosWebSocketBundle 4.0. Use the ratchet/pawl package instead.)
62+
enabled: false
63+
host: ~ # Required
64+
port: ~ # Required
65+
ssl: false
66+
origin: null
67+
pushers: # Deprecated (Since gos/web-socket-bundle 3.1: The "pushers" node is deprecated and will be removed in GosWebSocketBundle 4.0. Use the symfony/messenger component instead.)
68+
amqp: # Deprecated (Since gos/web-socket-bundle 3.1: The "amqp" node is deprecated and will be removed in GosWebSocketBundle 4.0. Use the symfony/messenger component instead.)
69+
enabled: false
70+
host: ~ # Required
71+
port: ~ # Required
72+
login: ~ # Required
73+
password: ~ # Required
74+
vhost: /
75+
read_timeout: 0
76+
write_timeout: 0
77+
connect_timeout: 0
78+
queue_name: gos_websocket
79+
exchange_name: gos_websocket_exchange
80+
wamp: # Deprecated (Since gos/web-socket-bundle 3.1: The "wamp" node is deprecated and will be removed in GosWebSocketBundle 4.0. Use the symfony/messenger component instead.)
81+
enabled: false
82+
host: ~ # Required
83+
port: ~ # Required
84+
ssl: false
85+
origin: null
6886
```

src/DependencyInjection/Configuration.php

Lines changed: 24 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,9 @@
1212
*/
1313
final class Configuration implements ConfigurationInterface
1414
{
15-
private const DEFAULT_TTL = 900;
16-
private const DEFAULT_CLIENT_STORAGE_SERVICE = 'gos_web_socket.client.driver.in_memory';
17-
private const DEFAULT_FIREWALL = 'ws_firewall';
18-
private const DEFAULT_ORIGIN_CHECKER = false;
19-
private const DEFAULT_KEEPALIVE_PING = false;
20-
private const DEFAULT_KEEPALIVE_INTERVAL = 30;
2115
public const PING_SERVICE_TYPE_DOCTRINE = 'doctrine';
2216
public const PING_SERVICE_TYPE_PDO = 'pdo';
2317

24-
/**
25-
* @deprecated to be removed in 4.0
26-
*/
27-
private const DEFAULT_PREFIX = '';
28-
2918
public function getConfigTreeBuilder(): TreeBuilder
3019
{
3120
$treeBuilder = new TreeBuilder('gos_web_socket');
@@ -35,29 +24,30 @@ public function getConfigTreeBuilder(): TreeBuilder
3524
->addDefaultsIfNotSet()
3625
->children()
3726
->scalarNode('session_handler')
38-
->example('@session.handler.pdo')
27+
->info('The service ID of the session handler service used to read session data.')
3928
->end()
4029
->variableNode('firewall')
41-
->example('secured_area')
42-
->defaultValue(static::DEFAULT_FIREWALL)
30+
->defaultValue('ws_firewall')
31+
->info('The name of the security firewall to load the authenticated user data for.')
4332
->end()
4433
->arrayNode('storage')
4534
->addDefaultsIfNotSet()
4635
->children()
4736
->scalarNode('driver')
48-
->defaultValue(static::DEFAULT_CLIENT_STORAGE_SERVICE)
49-
->example(static::DEFAULT_CLIENT_STORAGE_SERVICE)
37+
->defaultValue('gos_web_socket.client.driver.in_memory')
38+
->info('The service ID of the storage driver to use for storing connection data.')
5039
->end()
5140
->integerNode('ttl')
52-
->defaultValue(static::DEFAULT_TTL)
53-
->example('3600')
41+
->defaultValue(900)
42+
->info('The cache TTL (in seconds) for clients in storage.')
5443
->end()
5544
->scalarNode('prefix')
5645
->setDeprecated(...$this->getDeprecationParameters('The "%node%" node is deprecated and will be removed in GosWebSocketBundle 4.0.', '3.1'))
57-
->defaultValue(static::DEFAULT_PREFIX)
58-
->example('client')
46+
->defaultValue('')
47+
->end()
48+
->scalarNode('decorator')
49+
->info('The service ID of a decorator for the client storage driver.')
5950
->end()
60-
->scalarNode('decorator')->end()
6151
->end()
6252
->end()
6353
->end()
@@ -68,33 +58,31 @@ public function getConfigTreeBuilder(): TreeBuilder
6858
->arrayNode('server')
6959
->children()
7060
->scalarNode('host')
71-
->example('127.0.0.1')
61+
->info('The host IP address on the server which connections for the websocket server are accepted.')
7262
->cannotBeEmpty()
7363
->isRequired()
7464
->end()
7565
->scalarNode('port')
76-
->example('8080')
66+
->info('The port on the server which connections for the websocket server are accepted.')
7767
->isRequired()
7868
->end()
7969
->booleanNode('origin_check')
80-
->defaultValue(static::DEFAULT_ORIGIN_CHECKER)
81-
->example('true')
70+
->defaultValue(false)
71+
->info('Enables checking the Origin header of websocket connections for allowed values.')
8272
->end()
8373
->booleanNode('keepalive_ping')
84-
->defaultValue(static::DEFAULT_KEEPALIVE_PING)
85-
->example('true')
86-
->info('Flag indicating a keepalive ping should be enabled on the server')
74+
->defaultValue(false)
75+
->info('Flag indicating a keepalive ping should be enabled on the server.')
8776
->end()
8877
->integerNode('keepalive_interval')
89-
->defaultValue(static::DEFAULT_KEEPALIVE_INTERVAL)
90-
->example('30')
91-
->info('The time in seconds between each keepalive ping')
78+
->defaultValue(30)
79+
->info('The time in seconds between each keepalive ping.')
9280
->end()
9381
->arrayNode('router')
9482
->children()
9583
->arrayNode('resources')
9684
->beforeNormalization()
97-
->ifTrue(static function ($v) {
85+
->ifTrue(static function ($v): bool {
9886
foreach ($v as $resource) {
9987
if (!\is_array($resource)) {
10088
return true;
@@ -103,7 +91,7 @@ public function getConfigTreeBuilder(): TreeBuilder
10391

10492
return false;
10593
})
106-
->then(static function ($v) {
94+
->then(static function ($v): array {
10795
$resources = [];
10896

10997
foreach ($v as $resource) {
@@ -137,6 +125,7 @@ public function getConfigTreeBuilder(): TreeBuilder
137125
->end()
138126
->end()
139127
->arrayNode('origins')
128+
->info('A list of origins allowed to connect to the websocket server, must match the value from the "Origin" header of the HTTP request.')
140129
->scalarPrototype()
141130
->validate()
142131
->ifInArray(['localhost', '127.0.0.1'])
@@ -150,12 +139,12 @@ public function getConfigTreeBuilder(): TreeBuilder
150139
->arrayPrototype()
151140
->children()
152141
->scalarNode('name')
153-
->info('The name of the service to ping')
142+
->info('The name of the service to ping.')
154143
->cannotBeEmpty()
155144
->isRequired()
156145
->end()
157146
->enumNode('type')
158-
->info('The type of the service to be pinged; valid options are "doctrine" and "pdo"')
147+
->info('The type of the service to be pinged.')
159148
->isRequired()
160149
->values([self::PING_SERVICE_TYPE_DOCTRINE, self::PING_SERVICE_TYPE_PDO])
161150
->end()
@@ -170,12 +159,10 @@ public function getConfigTreeBuilder(): TreeBuilder
170159
->canBeEnabled()
171160
->children()
172161
->scalarNode('host')
173-
->example('127.0.0.1')
174162
->isRequired()
175163
->cannotBeEmpty()
176164
->end()
177165
->scalarNode('port')
178-
->example('1337')
179166
->isRequired()
180167
->end()
181168
->booleanNode('ssl')
@@ -209,12 +196,10 @@ private function addWampNode(): NodeDefinition
209196
->canBeEnabled()
210197
->children()
211198
->scalarNode('host')
212-
->example('127.0.0.1')
213199
->isRequired()
214200
->cannotBeEmpty()
215201
->end()
216202
->scalarNode('port')
217-
->example('1337')
218203
->isRequired()
219204
->end()
220205
->booleanNode('ssl')
@@ -240,12 +225,10 @@ private function addAmqpNode(): NodeDefinition
240225
->canBeEnabled()
241226
->children()
242227
->scalarNode('host')
243-
->example('127.0.0.1')
244228
->isRequired()
245229
->cannotBeEmpty()
246230
->end()
247231
->scalarNode('port')
248-
->example('5672')
249232
->isRequired()
250233
->end()
251234
->scalarNode('login')

0 commit comments

Comments
 (0)