@@ -6,6 +6,7 @@ use Moose;
66extends ' Catalyst::Plugin::Session::Store' ;
77use MooseX::Types::ElasticSearch qw( ES ) ;
88
9+ use MetaCPAN::ESConfig qw( es_doc_path ) ;
910use MetaCPAN::Server::Config ();
1011use MetaCPAN::Util qw( true false ) ;
1112
@@ -17,26 +18,12 @@ has _session_es => (
1718 default =>
1819 sub { MetaCPAN::Server::Config::config()-> {elasticsearch_servers } },
1920);
20- has _session_es_index => (
21- required => 1,
22- is => ' ro' ,
23- default => sub { shift -> _session_plugin_config-> {index } || ' user' }
24- );
25- has _session_es_type => (
26- required => 1,
27- is => ' ro' ,
28- default => sub { shift -> _session_plugin_config-> {type } || ' session' }
29- );
3021
3122sub get_session_data {
3223 my ( $self , $key ) = @_ ;
3324 if ( my ($sid ) = $key =~ / ^\w +:(.*)/ ) {
3425 my $data = eval {
35- $self -> _session_es-> get(
36- index => $self -> _session_es_index,
37- type => $self -> _session_es_type,
38- id => $sid ,
39- );
26+ $self -> _session_es-> get( es_doc_path(' session' ), id => $sid , );
4027 } || return undef ;
4128 if ( $key =~ / ^expires:/ ) {
4229 return $data -> {_source }-> {_expires };
@@ -52,8 +39,7 @@ sub store_session_data {
5239 if ( my ($sid ) = $key =~ / ^session:(.*)/ ) {
5340 $session -> {_expires } = $self -> session_expires;
5441 $self -> _session_es-> index (
55- index => $self -> _session_es_index,
56- type => $self -> _session_es_type,
42+ es_doc_path(' session' ),
5743 id => $sid ,
5844 body => $session ,
5945 refresh => true,
@@ -66,8 +52,7 @@ sub delete_session_data {
6652 if ( my ($sid ) = $key =~ / ^session:(.*)/ ) {
6753 eval {
6854 $self -> _session_es-> delete (
69- index => $self -> _session_es_index,
70- type => $self -> _session_es_type,
55+ es_doc_path(' session' ),
7156 id => $sid ,
7257 refresh => true,
7358 );
@@ -93,8 +78,6 @@ sub delete_expired_sessions { }
9378 MyApp->config(
9479 'Plugin::Session' => {
9580 servers => ':9200',
96- index => 'user',
97- type => 'session',
9881 } );
9982
10083=head1 DESCRIPTION
0 commit comments