@@ -33,19 +33,23 @@ final class Connection implements Link
3333
3434 /**
3535 * @param ConnectionConfig $config
36- * @param CancellationToken|null $config
36+ * @param CancellationToken|null $token
37+ * @param Socket\ClientConnectContext|null $context Note that TCP No Delay will be set to on automatically.
3738 *
3839 * @return Promise
3940 */
40- public static function connect (ConnectionConfig $ config , CancellationToken $ token = null ): Promise
41- {
42- $ token = $ token ?? new NullCancellationToken ();
43-
44- return call (function () use ($ config , $ token ) {
45- static $ connectContext ;
46-
47- $ connectContext = $ connectContext ?? (new Socket \ClientConnectContext ())->withTcpNoDelay ();
48- $ socket = yield Socket \connect ($ config ->getConnectionString (), $ connectContext , $ token );
41+ public static function connect (
42+ ConnectionConfig $ config ,
43+ CancellationToken $ token = null ,
44+ Socket \ClientConnectContext $ context = null
45+ ): Promise {
46+ $ token = $ token ?? new NullCancellationToken ;
47+
48+ $ context = $ context ?? new Socket \ClientConnectContext ;
49+
50+ return call (function () use ($ config , $ token , $ context ) {
51+ $ context = $ context ->withTcpNoDelay ();
52+ $ socket = yield Socket \connect ($ config ->getConnectionString (), $ context , $ token );
4953
5054 $ processor = new Internal \Processor ($ socket , $ config );
5155 yield $ processor ->connect ();
0 commit comments