All Projects → FriendsOfPHP → Consul Php Sdk

FriendsOfPHP / Consul Php Sdk

Licence: mit
PHP Consul SDK

Labels

Projects that are alternatives of or similar to Consul Php Sdk

Gentleman
Full-featured, plugin-driven, extensible HTTP client toolkit for Go
Stars: ✭ 886 (+207.64%)
Mutual labels:  sdk, consul
Qiskit Terra
Qiskit is an open-source SDK for working with quantum computers at the level of extended quantum circuits, operators, and algorithms.
Stars: ✭ 3,177 (+1003.13%)
Mutual labels:  sdk
Aspnet Servicediscovery Patterns
Samples of simple service discovery patterns with ASP .NET Core
Stars: ✭ 265 (-7.99%)
Mutual labels:  consul
Parse Sdk Dotnet
Parse SDK for .NET, Xamarin, Unity.
Stars: ✭ 272 (-5.56%)
Mutual labels:  sdk
Stream Chat Flutter
Stream Chat official Flutter SDK. Build your own chat experience using Dart and Flutter.
Stars: ✭ 220 (-23.61%)
Mutual labels:  sdk
Fw Spring Cloud
SpringCloud构建实战、从入门到高级,包含eureka、zuul、gateway、feign、ribbon、hystrix、mq、turbine、nacos、elk、consul、zookeeper、rocketmq、kafka、分布式事务(RocketMq、LCN、Seata)、分库分表(Sharding-JDBC)、分布式锁(Redis、Guava)、jwt、SkyWalking、Zipkin、bootadmin等使用案例
Stars: ✭ 276 (-4.17%)
Mutual labels:  consul
Wechatpy
WeChat SDK for Python
Stars: ✭ 3,016 (+947.22%)
Mutual labels:  sdk
Python Sdk
百度AI开放平台 Python SDK
Stars: ✭ 285 (-1.04%)
Mutual labels:  sdk
Easybluetooth
一款iOS BLE蓝牙调试工具,非常简单容易,也可以作为一个蓝牙库,快速集成和开发。 可以两步搞定蓝牙开发操作。 第一步连接设备,第二步特征读写数据。
Stars: ✭ 282 (-2.08%)
Mutual labels:  sdk
Py Stellar Base
Stellar client library for the Python language
Stars: ✭ 273 (-5.21%)
Mutual labels:  sdk
Cognitive Face Android
Cognitive Services Face client library for Android.
Stars: ✭ 273 (-5.21%)
Mutual labels:  sdk
Dynamixelsdk
ROBOTIS Dynamixel SDK (Protocol1.0/2.0)
Stars: ✭ 266 (-7.64%)
Mutual labels:  sdk
Phnt
Native API header files for the Process Hacker project.
Stars: ✭ 276 (-4.17%)
Mutual labels:  sdk
Postman Collection
Javascript module that allows a developer to work with Postman Collections
Stars: ✭ 265 (-7.99%)
Mutual labels:  sdk
Alan Sdk Android
Alan AI Android SDK adds a voice assistant or chatbot to your app. Supports Java, Kotlin.
Stars: ✭ 278 (-3.47%)
Mutual labels:  sdk
Azure Iot Sdk Python
A Python SDK for connecting devices to Microsoft Azure IoT services
Stars: ✭ 261 (-9.37%)
Mutual labels:  sdk
Artoolkitx
artoolkitX
Stars: ✭ 272 (-5.56%)
Mutual labels:  sdk
Dropbox Sdk Dotnet
The Official Dropbox API V2 SDK for .NET
Stars: ✭ 274 (-4.86%)
Mutual labels:  sdk
Ble examples
Additional examples to compliment TI's Bluetooth Low Energy Stack offerings.
Stars: ✭ 289 (+0.35%)
Mutual labels:  sdk
Gpmf Parser
Parser for GPMF™ formatted telemetry data used within GoPro® cameras.
Stars: ✭ 282 (-2.08%)
Mutual labels:  sdk

Consul SDK

Compatibility

This table shows this SDK compatibility regarding supported Guzzle/Symfony http client versions:

SDK Version Guzzle Version Symfony HTTP Client
1.x >=4, <6 N/A
2.x 6 N/A
3.x 6 N/A
4.x N/A 5

Installation

This library can be installed with composer:

composer require sensiolabs/consul-php-sdk

Usage

The simple way to use this SDK, is to instantiate the service factory:

$sf = new SensioLabs\Consul\ServiceFactory();

Then, a service could be retrieve from this factory:

$kv = $sf->get(\SensioLabs\Consul\Services\KVInterface::class);

Then, a service expose few methods mapped from the consul API:

$kv->put('test/foo/bar', 'bazinga');
$kv->get('test/foo/bar', ['raw' => true]);
$kv->delete('test/foo/bar');

All services methods follow the same convention:

$response = $service->method($mandatoryArgument, $someOptions);
  • All API mandatory arguments are placed as first;
  • All API optional arguments are directly mapped from $someOptions;
  • All methods return a raw http client response.

So if you want to acquire an exclusive lock:

// Start a session
$sessionId = $session->create()->json()['ID'];

// Lock a key / value with the current session
$lockAcquired = $kv->put('tests/session/a-lock', 'a value', ['acquire' => $sessionId])->json();

if (false === $lockAcquired) {
    $session->destroy($sessionId);

    echo "The lock is already acquire by another node.\n";
    exit(1);
}

echo "Do you jobs here....";
sleep(5);
echo "End\n";

$kv->delete('tests/session/a-lock');
$session->destroy($sessionId);

Available services

  • agent
  • catalog
  • health
  • kv
  • session

Some utilities

  • Lock handler: Simple class that implement a distributed lock
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].