Skip to content

Commit

Permalink
Merge pull request #66 from soketi/feature/rebranding-fixes
Browse files Browse the repository at this point in the history
Rebranding
  • Loading branch information
rennokki committed Nov 13, 2021
2 parents 634abf9 + 4095225 commit 067246a
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 22 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ jobs:
- name: Load Kubernetes fixtures
run: |
kubectl apply -f tests/fixtures/pws.yaml
kubectl apply -f tests/fixtures/soketi.yaml
- name: Copy environment variables
run: |
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ Network Watcher

Monitor Kubernetes containers for memory allowance and redirect new HTTP/WebSocket connections to pods that have enough memory to sustain them.

This can be generally used for any kind of server, but its main purpose was to redirect new WebSocket connections to pods that have enough memory to withstand them in [pWS server](https://github.com/soketi/pws).
This can be generally used for any kind of server, but its main purpose was to redirect new WebSocket connections to pods that have enough memory to withstand them in [soketi server](https://github.com/soketi/soketi).

Under the hood, it works by setting a pod label to either `yes`/`no` and you should make the Kubernetes Service to seek for pods by that label, with the value `yes`. You can find examples [in the documentation](https://rennokki.gitbook.io/soketi-pws/network-watcher/getting-started).
Under the hood, it works by setting a pod label to either `yes`/`no` and you should make the Kubernetes Service to seek for pods by that label, with the value `yes`. You can find examples [in the documentation](https://rennokki.gitbook.io/soketi/network-watcher/getting-started).

## 🤝 Supporting

Expand All @@ -24,7 +24,7 @@ Under the hood, it works by setting a pod label to either `yes`/`no` and you sho

## 📜 Documentation

Documentation about how to integrate Network Watcher with your pWS-running pods is available [here](https://rennokki.gitbook.io/soketi-pws/network-watcher/getting-started).
Documentation about how to integrate Network Watcher with your soketi-running pods is available [here](https://rennokki.gitbook.io/soketi-docs/network-watcher/getting-started).

## 🚀 Installation

Expand Down
6 changes: 3 additions & 3 deletions app/Commands/WatchNetworkCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class WatchNetworkCommand extends Command implements SignalableCommandInterface
{--server-port=6001 : The Server port.}
{--memory-percent=75 : The threshold at which new connections close for a specific server.}
{--interval=1 : The interval in seconds between each checks.}
{--kubernetes-label=pws.soketi.app/accepts-new-connections : The label to attach to the Kubernetes services.}
{--kubernetes-label=ws.soketi.app/accepts-new-connections : The label to attach to the Kubernetes services.}
{--test : Run only one loop for testing.}
';

Expand All @@ -34,7 +34,7 @@ class WatchNetworkCommand extends Command implements SignalableCommandInterface
*
* @var string
*/
protected $description = 'Run the Network watcher controller for the pWS server.';
protected $description = 'Run the Network watcher controller for the soketi server.';

/**
* The current pod the instance is running into.
Expand Down Expand Up @@ -75,7 +75,7 @@ public function getSubscribedSignals(): array
public function handleSignal(int $signal): void
{
// Simply just mark the pod as rejecting the new connections while it's terminating.
// This way, the pWS Server will close all existing connections internally,
// This way, the soketi Server will close all existing connections internally,
// but the Network Watcher will also mark the pod as not being able to receive new connections for
// the sole purpose of redirecting the traffic to other pods.
$this->pod->rejectNewConnections();
Expand Down
16 changes: 8 additions & 8 deletions tests/Feature/NetworkWatchTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class NetworkWatchTest extends TestCase
public function test_watch_pod_rejecting_connections()
{
/** @var \RenokiCo\PhpK8s\Kinds\K8sDeployment $deployment */
$deployment = LaravelK8s::getDeploymentByName('pws-server-test');
$deployment = LaravelK8s::getDeploymentByName('soketi-server-test');

while (! $deployment->allPodsAreRunning()) {
echo "Waiting for {$deployment->getName()} deployment to have pods running...";
Expand Down Expand Up @@ -42,7 +42,7 @@ public function test_watch_pod_rejecting_connections()

$pod->refresh();

$this->assertEquals('no', $pod->getLabel('pws.soketi.app/accepts-new-connections'));
$this->assertEquals('no', $pod->getLabel('ws.soketi.app/accepts-new-connections'));

$event = $pod->getEvents()->reverse()->first(function ($event) use ($pod) {
return $event->getAttribute('involvedObject.name') === $pod->getName() &&
Expand All @@ -55,7 +55,7 @@ public function test_watch_pod_rejecting_connections()
public function test_watch_pod_accepting_connections()
{
/** @var \RenokiCo\PhpK8s\Kinds\K8sDeployment $deployment */
$deployment = LaravelK8s::getDeploymentByName('pws-server-test');
$deployment = LaravelK8s::getDeploymentByName('https://rennokki.gitbook.io/soketi-docs/-server-test');

while (! $deployment->allPodsAreRunning()) {
echo "Waiting for {$deployment->getName()} deployment to have pods running...";
Expand Down Expand Up @@ -83,13 +83,13 @@ public function test_watch_pod_accepting_connections()

$pod->refresh();

$this->assertEquals('yes', $pod->getLabel('pws.soketi.app/accepts-new-connections'));
$this->assertEquals('yes', $pod->getLabel('ws.soketi.app/accepts-new-connections'));
}

public function test_signaling_should_incapacitate_the_pod()
{
/** @var \RenokiCo\PhpK8s\Kinds\K8sDeployment $deployment */
$deployment = LaravelK8s::getDeploymentByName('pws-server-test');
$deployment = LaravelK8s::getDeploymentByName('soketi-server-test');

while (! $deployment->allPodsAreRunning()) {
echo "Waiting for {$deployment->getName()} deployment to have pods running...";
Expand All @@ -102,7 +102,7 @@ public function test_signaling_should_incapacitate_the_pod()

$pod = $this->makePodAcceptNewConnections($pod, true);

$this->assertEquals('yes', $pod->getLabel('pws.soketi.app/accepts-new-connections'));
$this->assertEquals('yes', $pod->getLabel('ws.soketi.app/accepts-new-connections'));

/** @var WatchNetworkCommand $command */
$command = app(WatchNetworkCommand::class);
Expand All @@ -115,7 +115,7 @@ public function test_signaling_should_incapacitate_the_pod()

$pod->refresh();

$this->assertEquals('no', $pod->getLabel('pws.soketi.app/accepts-new-connections'));
$this->assertEquals('no', $pod->getLabel('ws.soketi.app/accepts-new-connections'));

$event = $pod->getEvents()->reverse()->first(function ($event) use ($pod) {
return $event->getAttribute('involvedObject.name') === $pod->getName() &&
Expand All @@ -135,7 +135,7 @@ public function test_signaling_should_incapacitate_the_pod()
protected function makePodAcceptNewConnections(K8sPod $pod, $accept = true)
{
$labels = array_merge($pod->getLabels(), [
'pws.soketi.app/accepts-new-connections' => $accept ? 'yes' : 'no',
'ws.soketi.app/accepts-new-connections' => $accept ? 'yes' : 'no',
]);

$pod->refresh()->setLabels($labels)->update();
Expand Down
14 changes: 7 additions & 7 deletions tests/fixtures/pws.yaml → tests/fixtures/soketi.yaml
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: pws-server-test
name: soketi-server-test
labels:
app: pws-server-test
app: soketi-server-test
state: testing
spec:
replicas: 1
selector:
matchLabels:
app: pws-server-test
app: soketi-server-test
state: testing
template:
metadata:
labels:
app: pws-server-test
app: soketi-server-test
state: testing
deployment-name: pws-server-test
deployment-name: soketi-server-test
spec:
containers:
- name: pws
image: quay.io/soketi/pws:0.6-16-alpine
- name: soketi
image: quay.io/soketi/soketi:0.13-16-alpine
env:
- name: PRESENCE_STORAGE_DATABASE
value: socket
Expand Down

0 comments on commit 067246a

Please sign in to comment.