-
-
20 Oct 2021 09:35:06 UTC
- Distribution: Search-Elasticsearch-Async
- Module version: 7.715
- Source (raw)
- Browse (raw)
- Changes
- Homepage
- How to Contribute
- Repository
- Issues
- Testers (272 / 0 / 0)
- Kwalitee
Bus factor: 1- 94.65% Coverage
- License: apache_2_0
- Activity
24 month- Tools
- Download (56.14KB)
- MetaCPAN Explorer
- Permissions
- Subscribe to distribution
- Permalinks
- This version
- Latest version
NAME
Search::Elasticsearch::Cxn::Mojo - An async Cxn implementation which uses Mojo::UserAgent
VERSION
version 7.715
DESCRIPTION
Provides an async HTTP Cxn class based on Mojo::UserAgent. The Mojo backend is fast, uses pure Perl, support proxies and https and provides persistent connections.
This class does Search::Elasticsearch::Role::Cxn, whose documentation provides more information, Search::Elasticsearch::Role::Async::Cxn, and Search::Elasticsearch::Role::Is_Async.
CONFIGURATION
connect_timeout
Unlike most HTTP backends, Mojo::UserAgent accepts a separate
connect_timeout
parameter, which defaults to2
seconds but can be reduced in an environment with low network latency.Inherited configuration
From Search::Elasticsearch::Role::Cxn
SSL/TLS
Search::Elasticsearch::Cxn::Mojo does no validation of the remote host by default.
This behaviour can be changed by passing the
ssl_options
parameter with theca
,cert
, andkey
options. For instance, to check that the remote host has a trusted certificate, and to avoid man-in-the-middle attacks, you could do the following:use Search::Elasticsearch::Async; my $es = Search::Elasticsearch::Async->new( cxn => 'Mojo', nodes => [ "https://node1.mydomain.com:9200", "https://node2.mydomain.com:9200", ], ssl_options => { ca => '/path/to/cacert.pem' } );
If the remote server cannot be verified, an Search::Elasticsearch::Error will be thrown.
If you want your client to present its own certificate to the remote server, then use:
use Search::Elasticsearch::Async; my $es = Search::Elasticsearch::Async->new( cxn => 'Mojo', nodes => [ "https://node1.mydomain.com:9200", "https://node2.mydomain.com:9200", ], ssl_options => { ca => '/path/to/cacert.pem' cert => '/path/to/client.pem', key => '/path/to/client.pem' } );
METHODS
perform_request()
$self->perform_request({ # required method => 'GET|HEAD|POST|PUT|DELETE', path => '/path/of/request', qs => \%query_string_params, # optional data => $body_as_string, mime_type => 'application/json', timeout => $timeout }) ->then(sub { my ($status,body) = @_; ...})
Sends the request to the associated Elasticsearch node and returns a
$status
code and the decoded response$body
, or throws an error if the request failed.Inherited methods
From Search::Elasticsearch::Role::Cxn
From Search::Elasticsearch::Role::Async::Cxn
SEE ALSO
AUTHOR
Enrico Zimuel <enrico.zimuel@elastic.co>
COPYRIGHT AND LICENSE
This software is Copyright (c) 2021 by Elasticsearch BV.
This is free software, licensed under:
The Apache License, Version 2.0, January 2004
Module Install Instructions
To install Search::Elasticsearch::Async, copy and paste the appropriate command in to your terminal.
cpanm Search::Elasticsearch::Async
perl -MCPAN -e shell install Search::Elasticsearch::Async
For more information on module installation, please visit the detailed CPAN module installation guide.