Skip to content
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
4 changes: 2 additions & 2 deletions dub.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"copyright": "Copyright © 2014, David Monagle",
"authors": ["David Monagle"],
"dependencies": {
"vibe-d": "~>0.7.25",
"vibe-d": "~>0.8.0",
"feature-test-d": "~>1.0.4"
},
"configurations": [
Expand All @@ -13,5 +13,5 @@
"name": "elasticsearch-d"
}
],
"license": "MIT",
"license": "MIT"
}
11 changes: 11 additions & 0 deletions dub.sdl
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name "elasticsearch-d"
description "A D Elasticsearch library with an API similar to the official Elasticsearch packages for other languages."
authors "David Monagle"
copyright "Copyright © 2014, David Monagle"
license "MIT"
dependency "vibe-d" version="~>0.8.5"
dependency "feature-test-d" version="~>1.0.4"
dependency "undead" version="~master"
configuration "elasticsearch-d" {
targetType "library"
}
2 changes: 2 additions & 0 deletions source/elasticsearch/api/parameters.d
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ unittest {

/// Throws an argument exception if the given parameter is not included in `p`
void enforceParameter(const ref ESParams p, string name) {
import std.exception : enforce;
enforce(p.hasField(name), new ArgumentException(p, name ~ " parameter is required"));
}

Expand All @@ -103,6 +104,7 @@ string esEscape(string value) {

/// Takes an array of strings representing a path and returns a clean path string
string esPathify(string[] path ...) {
import undead.string : squeeze;
auto stripped = array(path.map!((p) => p.strip));
auto cleanPath = stripped.remove!((p) => !p.length);
auto returnString = cleanPath.join("/");
Expand Down
6 changes: 3 additions & 3 deletions source/elasticsearch/transport/http/vibe.d
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,15 @@ override:
Response performTransportRequest(Connection connection, RequestMethod method, string path, ESParams parameters, string requestBody = "") {
Response response;
requestHTTP(connection.fullURL(path, parameters),
(scope req) {
(scope HTTPClientRequest req) {
req.method = vibeTransportRequestMethod(method);
if (requestBody != "") {
req.writeBody(cast(ubyte[])requestBody);
}
logDebugV("ES Transport Request: %s %s", method, path);
if (requestBody.length) logTrace("ES Transport Request Body: \n%s", requestBody);
},
(scope res) {
(scope HTTPClientResponse res) {
response.status = res.statusCode;
response.headers = res.headers;
if (method != RequestMethod.HEAD) {
Expand All @@ -59,7 +59,7 @@ override:
}
else {
switch(res.statusCode) {
case(HTTPStatus.gatewayTimeout, HTTPStatus.requestTimeout):
case HTTPStatus.gatewayTimeout, HTTPStatus.requestTimeout:
throw new HostUnreachableException(connection);
default:
auto responseBody = res.bodyReader.readAllUTF8();
Expand Down
2 changes: 2 additions & 0 deletions source/elasticsearch/transport/transport.d
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ struct Host {
string password;

@property string url() {
import std.conv : to;
auto urlString = protocol ~ "://";
if (user.length) urlString ~= user ~ ":" ~ password ~ "@";
urlString ~= hostName ~ ":" ~ to!string(port);
Expand Down Expand Up @@ -129,6 +130,7 @@ class Transport {

Response performRequest(RequestMethod method, string path, ESParams parameters = ESParams(), string requestBody = "") {
// TODO: Make this more like the official method where it logs failures and automatically reloads connections on failure etc...
import std.conv : to;
int tries;
bool success;

Expand Down