Last active
July 5, 2017 03:07
-
-
Save kkkw/896e806fde9becedaf4c73f594553b52 to your computer and use it in GitHub Desktop.
sample
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Foo\Queue\Contract; | |
interface Client | |
{ | |
public static function get_instance(); | |
public function message($mesage); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Foo\Queue; | |
use Foo\Queue\Contract\Client; | |
class LocalClient implements Client | |
{ | |
public static function get_instance() | |
{ | |
return new static(); | |
} | |
public function message($message) | |
{ | |
//nothing to do on local | |
return false; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Foo\Queue; | |
use Foo\Aws\Sqs\Client as AwsClient; | |
class Manager | |
{ | |
/** | |
* @return \Geenie\Queue\Contract\Client | |
*/ | |
public static function get_client() | |
{ | |
$is_aws_active = true; | |
if ($is_aws_active) { | |
return AwsClient::get_instance(); | |
} else { | |
return LocalClient::get_instance(); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Foo\Aws\Sqs; | |
use Foo\Queue\Contract\Client as ClientInterface; | |
class SqsClient implements ClientInterface | |
{ | |
public static function get_instance() | |
{ | |
return new static(); | |
} | |
public function message($message) | |
{ | |
$this->client->sendMessage($message); | |
return true; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment