NAME
Net::STF::Client - STF Client
SYNOPSIS
use Net::STF::Client;
my $client = Net::STF::Client->new(
url => "http://stf.example.com",
repl_count => 3,
);
# If you want to use Basic Auth:
# my $client = Net::STF::Client->new(
# ... other params ...
# username => ....,
# password => ....,
# );
# direct CRUD from the client (fastest if you have the URL)
$object = $client->put_object( $url, $content, \%opts );
$object = $client->get_object( $url, \%opts );
$bool = $client->delete_object( $url, \%opts );
$bool = $client->delete_bucket( $url, \%opts );
# bucket-oriented interface
my $bucket = $client->create_bucket( $bucket_name );
$object = $bucket->put_object( $key, $content, \%opts );
$object = $bucket->get_object( $key, \%opts );
$bool = $bucket->del_object( $key, \%opts );
$bool = $bucket->delete( $recursive );
# object data
$object->url;
$object->key;
$object->content;
DESCRIPTION
Net::STF::Client implements the STF protocol to talk to STF servers.
METHODS
$class->new(%args)
- url
-
The base URL for your STF server. Required if you're going to use the bucket-oriented interface.
- repl_count
-
The default number of replicas to request when creating new objects. You may override this setting during a call to put_object(), but if unspecified, this value will be used as default.
If you don't specify this value in the constructor call, default value of 3 will be used.
- username
-
Username used for basic authentication. Leave blank if your server does not use basic authentiation.
- password
-
Password used for basic authentication. Leave blank if your server does not use basic authentiation.
- agent_name
-
The user agent name used when accessing the STF server. If unspecified, "Net::STF::Client/$VERSION" will be used as default.
- furl
-
Furl::HTTP object to talk to the STF server. You only need to provide this if you want to customize the behavior of Furl::HTTP object, which is pretty rare.
$object = $client->put_object( $url, $content, \%opts );
- $content (Any)
-
The object value to be stored. Can be anything that Furl::HTTP can handle when making a POST request.
- $url (Str)
-
The URL to put your object.
If the url parameter was supplied, you may specify a URL fragment containing the"$bucket_name/$object_name"
So these are equivalent:
my $stf_base = "http://stf.mycompany.com/"; my $bucket_name = "mybucket"; my $object_name = "path/to/object.dat"; # Complete URL { my $client = Net::STF::Client->new(); $client->put_object( "$stf_base/$bucket_name/$object_name", ... ); } # URL fragment { my $client = Net::STF::Client->new( url => $stf_base ); $client->put_object( "$bucket_name/$object_name", ... ); }
- %opts
-
- repl_count (Int)
-
Specify if you want to override the default X-STF-Replication-Count value:
# Make a lot of replicas for this object! $client->put_object( $url, $content, { repl_count => 30 } ); # Use whatever default in $client $client->put_object( $url, $content );
- consistency (Int)
-
Specify if you want to set the X-STF-Consistency value.
- headers
-
Appended to headers sent by Furl::HTTP
- write_file
-
Passed to Furl::HTTP
- write_code
-
Passed to Furl::HTTP
$object = $client->get_object( $url, \%opts );
- url (Str)
-
See docs for put_object() for details
- %opts
-
- headers
-
Appended to headers sent by Furl::HTTP
- write_file
-
Passed to Furl::HTTP
- write_code
-
Passed to Furl::HTTP
$bool = $client->delete_object( $url, \%opts );
- url (Str)
-
See docs for put_object() for details
- %opts
-
- headers
-
Appended to headers sent by Furl::HTTP
- write_file
-
Passed to Furl::HTTP
- write_code
-
Passed to Furl::HTTP
$bool = $client->delete_bucket( $url, \%opts );
- url (Str)
-
See docs for put_object() for details
- %opts
-
- headers
-
Appended to headers sent by Furl::HTTP
- write_file
-
Passed to Furl::HTTP
- write_code
-
Passed to Furl::HTTP
SEE ALSO
AUTHOR
Daisuke Maki <daisuke@endeworks.jp>
COPYRIGHT AND LICENSE
Copyright (C) 2011 by Daisuke Maki
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.0 or, at your option, any later version of Perl 5 you may have available.