- Class Interface
- Instance Interface
- Copyright and License
PGXN::API::Sync - Sync from a PGXN mirror and update the index
use PGXN::API::Sync; PGXN::API::Sync->new( source => $source, rsync_path => $rsync_path, verbose => $verbose, )->run;
This module provides the implementation for pgxn_api_sync, the command-line utility for syncing to a PGXN mirror and creating the API. It syncs to the specified PGXN rsync source URL, which should be a PGXN mirror server, and then verifies and unpacks newly-uploaded distributions and hands them off to PGXN::API::Indexer to index.
my $sync = PGXN::API::Sync->new(%params);
Creates and returns a new PGXN::API::Sync object. The supported parameters are:
Path to the rsync executable. Defaults to
rsync, which should work find if there is an executable with that name in your path.
rsyncURL specifying the source from which to sync. The source should be an
rsyncserver serving up a PGXN mirror source as created or mirrored from a PGXN Manager server.
An incremental integer specifying the level of verbosity to use during a sync. By default, PGXN::API::Sync runs in quiet mode, where only errors are emitted to
Runs the sync,
rsyncing from the source mirror server, verifying and unpacking distributions, and handing them off to the indexer for indexing. This is the main method called by pgxn_api_sync to just do the job.
rsyncs from the source mirror server. Called by
Parses the log generated by the execution of
run_rsync() for new distribution META.json files and passes any found off to
validate_distribution() and "add_distribution" in PGXN::API::Indexer for validation, unpacking, and indexing. Called internally by
my $regex = $sync->regex_for_uri_template('download');
Returns a regular expression that will match the path to a file in the rsync logs. The regular expression is created from a named URI template as loaded from the /index.json file synced from the mirror server. Used internally to parse the paths to distribution files from the rsync logs so that they can be validated, unpacked, and indexed.
my $download = $sync->download_for($meta);
Given the metadata loaded from a mirror server META.json file, returns the path to the download file for the distribution. Used internally by
validate_distribution() to find the file to validate.
my $params = $sync->validate_distribution($path_to_dist_meta);
Given the path to a distribution META.json file, this method validates the digest for the download file and unpacks it. Returns parameters suitable for passing to "add_distribution" in PGXN::Indexer for indexing.
my $digest = $sync->digest_for($zipfile);
Returns the SHA-1 hex digest for a distribution file (or any file, really). Called by
Given a download file for a distribution, and the metadata loaded from the
META.json describing the download, this method unpacks the download under the src/ directory under the document root. Each file will be readable by all users. This provides the browsable file interface for the API server to serve. Called internally by
my $rsync_path = $sync->rsync_path; $sync->rsync_path($rsync_path);
Get or set the path to the
my $source = $sync->source; $sync->source($source);
Get or set the source
rsync URL from which to sync a PGXN mirror.
my $verbose = $sync->verbose; $sync->verbose($verbose);
Get or set an incremental verbosity. The higher the integer specified, the more verbose the sync.
my $log_file = $sync->log_file; $sync->log_file($log_file);
Get or set the path to use for the
rsync log file. This file will then be parsed by
update_index for new distributions to index.
my $templates = $pgxn->mirror_uri_templates;
Returns a hash reference of the URI templates loaded from the index.json file in the mirror root. The keys are the names of the templates, and the values are URI::Template objects.
David E. Wheeler <firstname.lastname@example.org>
Copyright and License
Copyright (c) 2011-2013 David E. Wheeler.
This module is free software; you can redistribute it and/or modify it under the PostgreSQL License.
Permission to use, copy, modify, and distribute this software and its documentation for any purpose, without fee, and without a written agreement is hereby granted, provided that the above copyright notice and this paragraph and the following two paragraphs appear in all copies.
In no event shall David E. Wheeler be liable to any party for direct, indirect, special, incidental, or consequential damages, including lost profits, arising out of the use of this software and its documentation, even if David E. Wheeler has been advised of the possibility of such damage.
David E. Wheeler specifically disclaims any warranties, including, but not limited to, the implied warranties of merchantability and fitness for a particular purpose. The software provided hereunder is on an "as is" basis, and David E. Wheeler has no obligations to provide maintenance, support, updates, enhancements, or modifications.