Skip to content

Commit f9828fa

Browse files
Merge pull request #14 from ByteInternet/varnish-platform-configuration
Support varnish platform configuration.
2 parents f9759ae + c80cce4 commit f9828fa

File tree

1 file changed

+103
-0
lines changed

1 file changed

+103
-0
lines changed
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
<?php
2+
3+
namespace Hypernode\DeployConfiguration\PlatformConfiguration;
4+
5+
use Hypernode\DeployConfiguration\ServerRole;
6+
use Hypernode\DeployConfiguration\ServerRoleConfigurableInterface;
7+
use Hypernode\DeployConfiguration\ServerRoleConfigurableTrait;
8+
use Hypernode\DeployConfiguration\StageConfigurableInterface;
9+
use Hypernode\DeployConfiguration\StageConfigurableTrait;
10+
use Hypernode\DeployConfiguration\TaskConfigurationInterface;
11+
12+
class VarnishConfiguration implements
13+
TaskConfigurationInterface,
14+
ServerRoleConfigurableInterface,
15+
StageConfigurableInterface
16+
{
17+
use ServerRoleConfigurableTrait;
18+
use StageConfigurableTrait;
19+
20+
/**
21+
* Defaults
22+
*/
23+
private const DEFAULT_FRONTEND_PORT = 6081;
24+
private const DEFAULT_BACKEND_PORT = 6082;
25+
private const DEFAULT_CONFIG_FILE = 'etc/varnish.vcl';
26+
private const DEFAULT_VARNISH_VERSION = '4.0';
27+
28+
/**
29+
* @var int
30+
*/
31+
private $frontendPort;
32+
33+
/**
34+
* @var int
35+
*/
36+
private $backendPort;
37+
38+
/**
39+
* @var string
40+
*/
41+
private $configFile;
42+
43+
/**
44+
* @var string
45+
*/
46+
private $version;
47+
48+
/**
49+
* @var array
50+
*/
51+
private $arguments;
52+
53+
/**
54+
* @param int $frontendPort
55+
* @param int $backendPort
56+
* @param string $configFile
57+
* @param string $version
58+
* @param array $arguments
59+
*/
60+
public function __construct(
61+
$frontendPort = self::DEFAULT_FRONTEND_PORT,
62+
$backendPort = self::DEFAULT_BACKEND_PORT,
63+
$configFile = self::DEFAULT_CONFIG_FILE,
64+
$version = self::DEFAULT_VARNISH_VERSION,
65+
array $arguments = []
66+
) {
67+
$this->frontendPort = $frontendPort;
68+
$this->backendPort = $backendPort;
69+
$this->configFile = $configFile;
70+
$this->version = $version;
71+
$this->arguments = $arguments;
72+
73+
$this->setServerRoles([ServerRole::APPLICATION, ServerRole::LOAD_BALANCER]);
74+
}
75+
76+
public function getConfigFile(): string
77+
{
78+
return $this->configFile;
79+
}
80+
81+
public function getFrontendPort(): int
82+
{
83+
return $this->frontendPort;
84+
}
85+
86+
public function getBackendPort(): int
87+
{
88+
return $this->backendPort;
89+
}
90+
91+
public function getVersion(): string
92+
{
93+
return $this->version;
94+
}
95+
96+
/**
97+
* @return array
98+
*/
99+
public function getArguments(): array
100+
{
101+
return $this->arguments;
102+
}
103+
}

0 commit comments

Comments
 (0)