k8s/ws-ratchet

基于 Ratchet 的 k8s/client 的 websocket 适配器

1.1.1 2021-12-11 21:04 UTC

This package is auto-updated.

Last update: 2024-08-29 05:45:32 UTC


README

此库为 k8s/client 库提供了一个基于 Ratchet 的 websocket 适配器。

通用 K8s 库用法/配置选项

  1. 安装库

composer require k8s/ws-ratchet

注意:如果您不需要更改任何 TLS 设置,那么这就足够了。

  1. 如果您需要配置任何选项,则可以使用以下方法设置这些选项,并使用 websocket 与它们一起使用
use K8s\Client\K8s;
use K8s\Client\Options;
use K8s\WsRatchet\RatchetWebsocketAdapter;

$options = [
    # Set a timeout for the websocket connection
    'timeout' => 15,
    # Can toggle these to false if you are using a self-signed cert
    'tls' => [
        'verify_peer' => true,
        'verify_peer_name' => true,
    ],
];

$websocket = new RatchetWebsocketAdapter($options);

# You can then pass the new websocket adapter in the options to be used
$options = new Options('k8s.endpoint.local');
$options->setWebsocketClient($websocket);

# Construct K8s to use the new websocket in the options
$k8s = new K8s($options);