Lines 672-680
sub AUTOLOAD
Link Here
|
672 |
|
672 |
|
673 |
$Zconn = C4::Context->Zconn |
673 |
$Zconn = C4::Context->Zconn |
674 |
|
674 |
|
675 |
Returns a connection to the Zebra database for the current |
675 |
Returns a connection to the Zebra database |
676 |
context. If no connection has yet been made, this method |
|
|
677 |
creates one and connects. |
678 |
|
676 |
|
679 |
C<$self> |
677 |
C<$self> |
680 |
|
678 |
|
Lines 682-713
C<$server> one of the servers defined in the koha-conf.xml file
Link Here
|
682 |
|
680 |
|
683 |
C<$async> whether this is a asynchronous connection |
681 |
C<$async> whether this is a asynchronous connection |
684 |
|
682 |
|
685 |
C<$auth> whether this connection has rw access (1) or just r access (0 or NULL) |
|
|
686 |
|
687 |
|
688 |
=cut |
683 |
=cut |
689 |
|
684 |
|
690 |
sub Zconn { |
685 |
sub Zconn { |
691 |
my ($self, $server, $async, $auth, $piggyback, $syntax) = @_; |
686 |
my ($self, $server, $async ) = @_; |
692 |
#TODO: We actually just ignore the auth and syntax parameter |
687 |
my $cache_key = join ('::', (map { $_ // '' } ($server, $async ))); |
693 |
#It also looks like we are not passing auth, piggyback, syntax anywhere |
688 |
$context->{"Zconn"}->{$cache_key}->destroy() if defined($context->{"Zconn"}->{$cache_key}); #destroy old connection before making a new one |
694 |
|
689 |
$context->{"Zconn"}->{$cache_key} = &_new_Zconn( $server, $async ); |
695 |
my $cache_key = join ('::', (map { $_ // '' } ($server, $async, $auth, $piggyback, $syntax))); |
690 |
return $context->{"Zconn"}->{$cache_key}; |
696 |
if ( defined($context->{"Zconn"}->{$cache_key}) && (0 == $context->{"Zconn"}->{$cache_key}->errcode()) ) { |
|
|
697 |
return $context->{"Zconn"}->{$cache_key}; |
698 |
# No connection object or it died. Create one. |
699 |
}else { |
700 |
# release resources if we're closing a connection and making a new one |
701 |
# FIXME: this needs to be smarter -- an error due to a malformed query or |
702 |
# a missing index does not necessarily require us to close the connection |
703 |
# and make a new one, particularly for a batch job. However, at |
704 |
# first glance it does not look like there's a way to easily check |
705 |
# the basic health of a ZOOM::Connection |
706 |
$context->{"Zconn"}->{$cache_key}->destroy() if defined($context->{"Zconn"}->{$cache_key}); |
707 |
|
708 |
$context->{"Zconn"}->{$cache_key} = &_new_Zconn( $server, $async, $piggyback ); |
709 |
return $context->{"Zconn"}->{$cache_key}; |
710 |
} |
711 |
} |
691 |
} |
712 |
|
692 |
|
713 |
=head2 _new_Zconn |
693 |
=head2 _new_Zconn |
Lines 725-731
C<$auth> whether this connection has rw access (1) or just r access (0 or NULL)
Link Here
|
725 |
=cut |
705 |
=cut |
726 |
|
706 |
|
727 |
sub _new_Zconn { |
707 |
sub _new_Zconn { |
728 |
my ( $server, $async, $piggyback ) = @_; |
708 |
my ( $server, $async ) = @_; |
729 |
|
709 |
|
730 |
my $tried=0; # first attempt |
710 |
my $tried=0; # first attempt |
731 |
my $Zconn; # connection object |
711 |
my $Zconn; # connection object |
Lines 761-767
sub _new_Zconn {
Link Here
|
761 |
$o->option(user => $user) if $user && $password; |
741 |
$o->option(user => $user) if $user && $password; |
762 |
$o->option(password => $password) if $user && $password; |
742 |
$o->option(password => $password) if $user && $password; |
763 |
$o->option(async => 1) if $async; |
743 |
$o->option(async => 1) if $async; |
764 |
$o->option(count => $piggyback) if $piggyback; |
|
|
765 |
$o->option(cqlfile=> $context->{"server"}->{$server}->{"cql2rpn"}); |
744 |
$o->option(cqlfile=> $context->{"server"}->{$server}->{"cql2rpn"}); |
766 |
$o->option(cclfile=> $context->{"serverinfo"}->{$server}->{"ccl2rpn"}); |
745 |
$o->option(cclfile=> $context->{"serverinfo"}->{$server}->{"ccl2rpn"}); |
767 |
$o->option(preferredRecordSyntax => $syntax); |
746 |
$o->option(preferredRecordSyntax => $syntax); |
768 |
- |
|
|