Skip to content

Commit

Permalink
added honeycomb storage provider
Browse files Browse the repository at this point in the history
  • Loading branch information
mwimmer-bcx committed Nov 26, 2024
1 parent fdae7bf commit 58f2b4b
Show file tree
Hide file tree
Showing 3 changed files with 94 additions and 1 deletion.
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';
}
}

0 comments on commit 58f2b4b

Please sign in to comment.