info > DBI::Gofer::Execute

DBI::Gofer::Execute(3pUser Contributed Perl Documentation DBI::Gofer::Execute(3pm)

๐Ÿ“› NAME

DBI::Gofer::Execute โ€” Executes Gofer requests and returns Gofer responses

๐Ÿš€ Quick Reference

Use CaseCommandDescription
Create executor$executor = DBI::Gofer::Execute->new({ ...config... })๐Ÿ”ง Instantiate a new Gofer executor with configuration options
Execute request$response = $executor->execute_request($request)โšก Execute a DBI::Gofer::Request and return a DBI::Gofer::Response
Check requestcheck_request_sub => \&sub๐Ÿ” Validate or transform incoming requests
Check responsecheck_response_sub => \&sub๐Ÿ” Inspect or modify outgoing responses
Force DSNforced_connect_dsn => "dbi:Driver:dbname"๐Ÿ”— Override the DSN in all requests
Set default DSNdefault_connect_dsn => "dbi:Driver:dbname"๐Ÿ”— Provide a fallback DSN when request has none
Force attributesforced_connect_attributes => \%attrโš™๏ธ Override connect() attributes from requests
Limit cached DBHmax_cached_dbh_per_drh => 10๐Ÿ“Š Cap cached database handles per driver
Limit cached STHmax_cached_sth_per_dbh => 1000๐Ÿ“Š Cap cached statement handles per connection
Single resultsetforced_single_resultset => 1๐Ÿ“„ Only fetch and return the first result set
Track recenttrack_recent => 10๐Ÿ“ˆ Keep recent requests/responses for diagnostics
Random testingforced_gofer_random => "fail=0.01%,do,delay60=1%,execute"๐Ÿงช Simulate failures and delays for testing

๐Ÿ“ SYNOPSIS

  $executor = DBI::Gofer::Execute->new( { ...config... });

  $response = $executor->execute_request( $request );

๐Ÿ“– DESCRIPTION

Accepts a DBI::Gofer::Request object, executes the requested DBI method calls, and returns a DBI::Gofer::Response object.

Any error, including any internal 'fatal' errors are caught and converted into a DBI::Gofer::Response object.

This module is usually invoked by a 'server-side' Gofer transport module. They usually have names in the DBI::Gofer::Transport::* namespace. Examples include: DBI::Gofer::Transport::stream and DBI::Gofer::Transport::mod_perl.

โš™๏ธ CONFIGURATION

๐Ÿ” check_request_sub

If defined, it must be a reference to a subroutine that will 'check' the request. It is passed the request object and the executor as its only arguments.

The subroutine can either return the original request object or die with a suitable error message (which will be turned into a Gofer response).

It can also construct and return a new request that should be executed instead of the original request.

๐Ÿ” check_response_sub

If defined, it must be a reference to a subroutine that will 'check' the response. It is passed the response object, the executor, and the request object. The sub may alter the response object and return undef, or return a new response object.

This mechanism can be used to, for example, terminate the service if specific database errors are seen.

๐Ÿ”— forced_connect_dsn

If set, this DSN is always used instead of the one in the request.

๐Ÿ”— default_connect_dsn

If set, this DSN is used if forced_connect_dsn is not set and the request does not contain a DSN itself.

โš™๏ธ forced_connect_attributes

A reference to a hash of connect() attributes. Individual attributes in forced_connect_attributes will take precedence over corresponding attributes in the request.

โš™๏ธ default_connect_attributes

A reference to a hash of connect() attributes. Individual attributes in the request take precedence over corresponding attributes in default_connect_attributes.

๐Ÿ“Š max_cached_dbh_per_drh

If set, the loaded drivers will be checked to ensure they don't have more than this number of cached connections. There is no default value. This limit is not enforced for every request.

๐Ÿ“Š max_cached_sth_per_dbh

If set, all the cached statement handles will be cleared once the number of cached statement handles rises above this limit. The default is 1000.

๐Ÿ“„ forced_single_resultset

If true, then only the first result set will be fetched and returned in the response.

๐Ÿ“ค forced_response_attributes

A reference to a data structure that can specify extra attributes to be returned in responses.

  forced_response_attributes => {
      DriverName => {
          dbh => [ qw(dbh_attrib_name) ],
          sth => [ qw(sth_attrib_name) ],
      },
  },

This can be useful in cases where the driver has not implemented the private_attribute_info() method and DBI::Gofer::Execute's own fallback list of private attributes doesn't include the driver or attributes you need.

๐Ÿ“ˆ track_recent

If set, specifies the number of recent requests and responses that should be kept by the update_stats() method for diagnostics. See DBI::Gofer::Transport::mod_perl.

Note that this setting can significantly increase memory use. Use with caution.

๐ŸŽฒ forced_gofer_random

Enable forced random failures and/or delays for testing. See DBI_GOFER_RANDOM below.

๐Ÿ”Œ DRIVER-SPECIFIC ISSUES

Gofer needs to know about any driver-private attributes that should have their values sent back to the client.

If the driver doesn't support private_attribute_info() method, and very few do, then the module falls back to using some hard-coded details, if available, for the driver being used. Currently hard-coded details are available for the mysql, Pg, Sybase, and SQLite drivers.

๐Ÿงช TESTING

DBD::Gofer, DBD::Execute and related packages are well tested by executing the DBI test suite with DBI_AUTOPROXY configured to route all DBI calls via DBD::Gofer.

Because Gofer includes timeout and 'retry on error' mechanisms there is a need for some way to trigger delays and/or errors. This can be done via the forced_gofer_random configuration item, or else the DBI_GOFER_RANDOM environment variable.

๐ŸŽฒ DBI_GOFER_RANDOM

The value of the forced_gofer_random configuration item (or else the DBI_GOFER_RANDOM environment variable) is treated as a series of tokens separated by commas.

The tokens can be one of three types:

For example:

  $executor = DBI::Gofer::Execute->new( {
    forced_gofer_random => "fail=0.01%,do,delay60=1%,execute",
  });

will cause the do() method to fail for 0.01% of calls, and the execute() method to fail 0.01% of calls and be delayed by 60 seconds on 1% of calls.

If the percentage value (R) is negative then instead of the failures being triggered randomly (via the rand() function) they are triggered via a sequence number. In other words fail=-20% will mean every fifth call will fail. Each method has a distinct sequence number.

๐Ÿ‘ค AUTHOR

Tim Bunce, <http://www.tim.bunce.name>

๐Ÿ“œ LICENCE AND COPYRIGHT

Copyright (c) 2007, Tim Bunce, Ireland. All rights reserved.

This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See perlartistic.


perl v5.34.0 โ€” 2026-06-22 โ€” DBI::Gofer::Execute(3pm)

DBI::Gofer::Execute
DBI::Gofer::Execute(3pUser Contributed Perl Documentation DBI::Gofer::Execute(3pm) ๐Ÿ“› NAME ๐Ÿš€ Quick Reference ๐Ÿ“ SYNOPSIS ๐Ÿ“– DESCRIPTION โš™๏ธ CONFIGURATION
๐Ÿ” check_request_sub ๐Ÿ” check_response_sub ๐Ÿ”— forced_connect_dsn ๐Ÿ”— default_connect_dsn โš™๏ธ forced_connect_attributes โš™๏ธ default_connect_attributes ๐Ÿ“Š max_cached_dbh_per_drh ๐Ÿ“Š max_cached_sth_per_dbh ๐Ÿ“„ forced_single_resultset ๐Ÿ“ค forced_response_attributes ๐Ÿ“ˆ track_recent ๐ŸŽฒ forced_gofer_random
๐Ÿ”Œ DRIVER-SPECIFIC ISSUES ๐Ÿงช TESTING
๐ŸŽฒ DBI_GOFER_RANDOM
๐Ÿ‘ค AUTHOR ๐Ÿ“œ LICENCE AND COPYRIGHT

Generated by phpman v4.9.26-5-g7740029 Author: Che Dong Under GNU General Public License
2026-08-14 20:17 @2600:1f28:365:80b0:4d23:66fa:c2bb:7bae
CrawledBy CCBot/2.0 (https://commoncrawl.org/faq/)
Valid XHTML 1.0 Transitional!Valid CSS!