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

ES testing #67

Open
wants to merge 5 commits into
base: master
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
32 changes: 16 additions & 16 deletions .platform/routes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,22 @@
type: upstream
upstream: "php:http"

"https://{default}/nodejs":
id: nodejs
type: upstream
upstream: "nodejs:http"
# "https://{default}/nodejs":
# id: nodejs
# type: upstream
# upstream: "nodejs:http"

"https://{default}/python":
id: python
type: upstream
upstream: "python:http"
# "https://{default}/python":
# id: python
# type: upstream
# upstream: "python:http"

"https://{default}/java":
id: java
type: upstream
upstream: "java:http"
# "https://{default}/java":
# id: java
# type: upstream
# upstream: "java:http"

"https://{default}/golang":
id: golang
type: upstream
upstream: "golang:http"
# "https://{default}/golang":
# id: golang
# type: upstream
# upstream: "golang:http"
142 changes: 84 additions & 58 deletions .platform/services.yaml
Original file line number Diff line number Diff line change
@@ -1,74 +1,100 @@
# This file defines services you want available to your application.

elasticsearch77:
type: elasticsearch:7.7
elasticsearch65:
type: elasticsearch:6.5
disk: 256
size: S
headlesschrome:
type: chrome-headless:73
size: S
influxdb18:
type: influxdb:1.8
elasticsearch68:
type: elasticsearch:6.8
disk: 256
size: S
kafka25:
type: kafka:2.5
disk: 512
size: S
mariadb104:
type: mariadb:10.4
elasticsearch72:
type: elasticsearch:7.2
disk: 256
size: S
memcached16:
type: memcached:1.6
size: S
mongodb36:
type: mongodb:3.6
disk: 1024
size: S
networkstorage:
type: network-storage:1.0
elasticsearch75:
type: elasticsearch:7.5
disk: 256
size: S
oraclemysql:
type: oracle-mysql:8.0
elasticsearch77:
type: elasticsearch:7.7
disk: 256
size: S
postgresql12:
type: postgresql:12
elasticsearch79:
type: elasticsearch:7.9
disk: 256
size: S
rabbitmq38:
type: rabbitmq:3.8
disk: 1024
size: S
redis6:
type: redis:6.0
size: S
solr86:
type: solr:8.6
elasticsearch710:
type: elasticsearch:7.10
disk: 256
size: S
configuration:
cores:
maincore:
conf_dir: !archive "solr-config"
endpoints:
solr:
core: maincore
vault:
type: vault-kms:1.6
disk: 512
size: S
configuration:
endpoints:
sign:
- policy: admin
key: vault-sign
type: sign
- policy: sign
key: vault-sign
type: sign
- policy: verify
key: vault-sign
type: sign


# headlesschrome:
# type: chrome-headless:73
# size: S
# influxdb18:
# type: influxdb:1.8
# disk: 256
# size: S
# kafka25:
# type: kafka:2.5
# disk: 512
# size: S
# mariadb104:
# type: mariadb:10.4
# disk: 256
# size: S
# memcached16:
# type: memcached:1.6
# size: S
# mongodb36:
# type: mongodb:3.6
# disk: 1024
# size: S
# networkstorage:
# type: network-storage:1.0
# disk: 256
# size: S
# oraclemysql:
# type: oracle-mysql:8.0
# disk: 256
# size: S
# postgresql12:
# type: postgresql:12
# disk: 256
# size: S
# rabbitmq38:
# type: rabbitmq:3.8
# disk: 1024
# size: S
# redis6:
# type: redis:6.0
# size: S
# solr86:
# type: solr:8.6
# disk: 256
# size: S
# configuration:
# cores:
# maincore:
# conf_dir: !archive "solr-config"
# endpoints:
# solr:
# core: maincore
# vault:
# type: vault-kms:1.6
# disk: 512
# size: S
# configuration:
# endpoints:
# sign:
# - policy: admin
# key: vault-sign
# type: sign
# - policy: sign
# key: vault-sign
# type: sign
# - policy: verify
# key: vault-sign
# type: sign
File renamed without changes.
File renamed without changes.
29 changes: 11 additions & 18 deletions main/.platform.app.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,12 @@ hooks:
curl -sS https://platform.sh/cli/installer | php

relationships:
elasticsearch: 'elasticsearch77:elasticsearch'
headlesschrome: 'headlesschrome:http'
influxdb: 'influxdb18:influxdb'
kafka: 'kafka25:kafka'
memcached: 'memcached16:memcached'
mongodb: 'mongodb36:mongodb'
oraclemysql: 'oraclemysql:mysql'
mysql: 'mariadb104:mysql'
postgresql: 'postgresql12:postgresql'
rabbitmq: 'rabbitmq38:rabbitmq'
redis: 'redis6:redis'
solr: 'solr86:solr'
vault: 'vault:sign'
elasticsearch65: 'elasticsearch65:elasticsearch'
elasticsearch68: 'elasticsearch68:elasticsearch'
elasticsearch72: 'elasticsearch72:elasticsearch'
elasticsearch75: 'elasticsearch75:elasticsearch'
elasticsearch79: 'elasticsearch79:elasticsearch'
elasticsearch710: 'elasticsearch710:elasticsearch'

# The size of the persistent disk of the application (in MB).
disk: 128
Expand All @@ -52,8 +45,8 @@ crons:
platform redeploy --yes --no-wait
fi

mounts:
networkstorage:
source: service
service: networkstorage
source_path: networkstorage
# mounts:
# networkstorage:
# source: service
# service: networkstorage
# source_path: networkstorage
10 changes: 5 additions & 5 deletions main/web/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,26 @@ <h1>Platform.sh examples</h1>
<h2>What relationships look like</h2>
<ul>
<li><a href="/relationships/elasticsearch">Elasticsearch</a></li>
<li><a href="/relationships/influxdb">InfluxDB</a></li>
<!-- <li><a href="/relationships/influxdb">InfluxDB</a></li>
<li><a href="/relationships/kafka">Kafka</a></li>
<li><a href="/relationships/memcached">Memcached</a></li>
<li><a href="/relationships/mongodb">MongoDB</a></li>
<li><a href="/relationships/mysql">MySQL/MariaDB</a></li>
<li><a href="/relationships/postgresql">PostgreSQL</a></li>
<li><a href="/relationships/redis">Redis</a></li>
<li><a href="/relationships/rabbitmq">RabbitMQ</a></li>
<li><a href="/relationships/solr">Solr</a></li>
<li><a href="/relationships/solr">Solr</a></li> -->
</ul>


<h2>Languages</h2>

<ul>
<li><a href="/golang">Go</a></li>
<!-- <li><a href="/golang">Go</a></li>
<li><a href="/java">Java</a></li>
<li><a href="/nodejs">Node.js</a></li>
<li><a href="/nodejs">Node.js</a></li> -->
<li><a href="/php">PHP</a></li>
<li><a href="/python">Python</a></li>
<!-- <li><a href="/python">Python</a></li> -->
</ul>


Expand Down
File renamed without changes.
15 changes: 6 additions & 9 deletions php/.platform.app.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,12 @@ hooks:
# to the application in the PLATFORM_RELATIONSHIPS variable. The right-hand
# side is in the form `<service name>:<endpoint name>`.
relationships:
database: 'mariadb104:mysql'
postgresql: 'postgresql12:postgresql'
solr: 'solr86:solr'
redis: 'redis6:redis'
elasticsearch: 'elasticsearch77:elasticsearch'
mongodb: 'mongodb36:mongodb'
rabbitmq: 'rabbitmq38:rabbitmq'
influxdb: 'influxdb18:influxdb'
memcached: 'memcached16:memcached'
elasticsearch65: 'elasticsearch65:elasticsearch'
elasticsearch68: 'elasticsearch68:elasticsearch'
elasticsearch72: 'elasticsearch72:elasticsearch'
elasticsearch75: 'elasticsearch75:elasticsearch'
elasticsearch79: 'elasticsearch79:elasticsearch'
elasticsearch710: 'elasticsearch710:elasticsearch'

# The size of the persistent disk of the application (in MB).
disk: 128
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
$config = new Config();

// Get the credentials to connect to the Elasticsearch service.
$credentials = $config->credentials('elasticsearch');
$credentials = $config->credentials('elasticsearch65');

try {
// The Elasticsearch library lets you connect to multiple hosts.
Expand Down
96 changes: 96 additions & 0 deletions php/examples/Elasticsearch68.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
<?php

declare(strict_types=1);

use Elasticsearch\ClientBuilder;
use Platformsh\ConfigReader\Config;

// Create a new config object to ease reading the Platform.sh environment variables.
// You can alternatively use getenv() yourself.
$config = new Config();

// Get the credentials to connect to the Elasticsearch service.
$credentials = $config->credentials('elasticsearch68');

try {
// The Elasticsearch library lets you connect to multiple hosts.
// On Platform.sh Standard there is only a single host so just
// register that.
$hosts = [
[
'scheme' => $credentials['scheme'],
'host' => $credentials['host'],
'port' => $credentials['port'],
]
];

// Create an Elasticsearch client object.
$builder = ClientBuilder::create();
$builder->setHosts($hosts);
$client = $builder->build();

$index = 'my_index';
$type = 'People';

// Index a few document.
$params = [
'index' => $index,
'type' => $type,
];

$names = ['Ada Lovelace', 'Alonzo Church', 'Barbara Liskov'];

foreach ($names as $name) {
$params['body']['name'] = $name;
$client->index($params);
}

// Force just-added items to be indexed.
$client->indices()->refresh(array('index' => $index));


// Search for documents.
$result = $client->search([
'index' => $index,
'type' => $type,
'body' => [
'query' => [
'match' => [
'name' => 'Barbara Liskov',
],
],
],
]);

if (isset($result['hits']['hits'])) {
print <<<TABLE
<table>
<thead>
<tr><th>ID</th><th>Name</th></tr>
</thead>
<tbody>
TABLE;
foreach ($result['hits']['hits'] as $record) {
printf("<tr><td>%s</td><td>%s</td></tr>\n", $record['_id'], $record['_source']['name']);
}
print "</tbody>\n</table>\n";
}

// Delete documents.
$params = [
'index' => $index,
'type' => $type,
];

$ids = array_map(function($row) {
return $row['_id'];
}, $result['hits']['hits']);

foreach ($ids as $id) {
$params['id'] = $id;
$client->delete($params);
}

} catch (Exception $e) {
print $e->getMessage();
}
Loading