Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add honeycomb storage provider #120

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 57 additions & 0 deletions src/Storage/Device/Honeycomb.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?php

namespace Utopia\Storage\Device;

use Utopia\Storage\Storage;

class Honeycomb extends S3
{
/**
* Regions constants
*/

//atm there is only one region. new regions will appear soon.
const EU_CENTRAL_1 = 'eu-de-fsn';

/**
* Honeycomb Constructor
*
* @param string $root
* @param string $accessKey
* @param string $secretKey
* @param string $bucket
* @param string $region
* @param string $acl
*/

public function __construct(string $root, string $accessKey, string $secretKey, string $bucket, string $region = self::EU_CENTRAL_1, string $acl = self::ACL_PRIVATE)
{
parent::__construct($root, $accessKey, $secretKey, $bucket, $region, $acl);
//https://s3.honeycomb-cloud.de/bucketname
$this->headers['host'] = 's3.honeycomb-cloud.de/'.$bucket;
}

/**
* @return string
*/
public function getName(): string
{
return 'Honeycomb Storage';
}

/**
* @return string
*/
public function getDescription(): string
{
return 'Honeycomb Storage';
}

/**
* @return string
*/
public function getType(): string
{
return Storage::DEVICE_HONEYCOMB;
}
}
4 changes: 3 additions & 1 deletion src/Storage/Storage.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ class Storage

const DEVICE_LINODE = 'linode';

const DEVICE_HONEYCOMB = 'honeycomb';

/**
* Devices.
*
Expand Down Expand Up @@ -121,4 +123,4 @@ public static function human(int $bytes, $decimals = 2, $system = 'metric')

return sprintf("%.{$decimals}f%s", $bytes / pow($mod, $factor), $units[$system][$factor]);
}
}
}
34 changes: 34 additions & 0 deletions tests/Storage/Device/HoneycombTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

namespace Utopia\Tests\Storage\Device;

use Utopia\Storage\Device\Honeycomb;
use Utopia\Tests\Storage\S3Base;

class HoneycombTest extends S3Base
{
protected function init(): void
{
$this->root = '/root';
$key = $_SERVER['HONEYCOMB_ACCESS_KEY'] ?? '';
$secret = $_SERVER['HONEYCOMB_SECRET'] ?? '';
$bucket = 'utopia-storage-tests';

$this->object = new Honeycomb($this->root, $key, $secret, $bucket, Honeycomb::EU_CENTRAL_1, HONEYCOMB::ACL_PRIVATE);
}

protected function getAdapterName(): string
{
return 'Honeycomb Storage';
}

protected function getAdapterType(): string
{
return $this->object->getType();
}

protected function getAdapterDescription(): string
{
return 'Honeycomb Storage';
}
}