REST-Neo4p

 view release on metacpan or  search on metacpan

lib/REST/Neo4p/Agent.pm  view on Meta::CPAN

chunked content, which is handled correctly by any of the underlying
user agents.

L<REST::Neo4p::Query> and L<REST::Neo4p::Batch> take advantage of
streamed responsed by retrieving and returning JSON objects
incrementally and (with the L<Mojo::UserAgent> backend) in a
non-blocking way. New Neo4j server versions may break the incremental
parsing. If this happens,  L<make a
ticket|https://rt.cpan.org/Public/Bug/Report.html?Queue=REST-Neo4p>. In
the meantime, you should be able to keep things going (albeit more
slowly) by turning off streaming at the agent:

 REST::Neo4p->agent->no_stream;

Streaming responses can be requested again by issuing

 REST::Neo4p->agent->stream

For batch API features, see L</Batch Mode>.

=head1 METHODS

lib/REST/Neo4p/Batch.pm  view on Meta::CPAN

    }

  }
  $agent->batch_mode(undef);
  return @errors;
}

# create new nodes, relationships as they are encountered
#
# TODO: handling indexes, queries? Prevent queries in batch mode?
# TODO: use JSON streaming from file

sub _register_object {
  my $decoded_batch_resp = shift;
  my ($id, $from, $body) = @{$decoded_batch_resp}{qw(id from body)};
  return unless $body;
  return if ($decoded_batch_resp->{status} !~ m/^2../); # ignore an error here
  my $obj;
  if ($body->{template}) {
    $obj = REST::Neo4p::Index->new_from_json_response($body);
  }

lib/REST/Neo4p/ParseStream.pm  view on Meta::CPAN

objects that are returned from cypher queries, transaction queries,
and batch requests.

Because of inconsistencies among the Neo4j response formats for each
of these functions, this module does a significant amount of
"hand-parsing". Currently the code will not be very robust to changes
in those response formats. If you find your query handling is breaking
with a new server version, L<make a
ticket|https://rt.cpan.org/Public/Bug/Report.html?Queue=REST-Neo4p>. In
the meantime, you should be able to keep things going (albeit more
slowly) by turning off streaming at the agent:

 use REST::Neo4p;
 REST::Neo4p->agent->no_stream;
 ...

=head1 SEE ALSO

L<REST::Neo4p>, L<REST::Neo4p::Query>, L<REST::Neo4p::Batch>,
L<HOP::Stream>, L<JSON::XS/"INCREMENTAL PARSING">.

t/002_agent.t  view on Meta::CPAN

		    'node url looks good';
		my ($version) = $ua->neo4j_version =~ /(^[0-9]+\.[0-9]+)/;
		cmp_ok $version, '>=', 1.8, 'Neo4j version >= 1.8 as required';
		like $ua->relationship_types, qr/^http.*types/, 
		    'relationship types url';
		ok $ua->post_node( [],{hyrax => 'rock badger' } ), 'create sample node';
		isa_ok $ua->raw_response, 'HTTP::Response';
		my $s = $ua->decoded_content->{self};
		(my $id) = $s =~ /([0-9]+)$/;
		like $ua->raw_response->header('Content-Type'), qr/stream=true/,
		    'server acknowledges streaming (expected default)';
		$ua->get_node($id);
		like $ua->raw_response->header('Content-Type'), qr/stream=true/,
		    'server acknowledges streaming (expected default)';
		ok $ua->no_stream, 'set no streaming';
		$ua->get_node($id);
		isa_ok $ua->raw_response, 'HTTP::Response';
		unlike $ua->raw_response->header('Content-Type'), qr/stream=true/,
		    'server acknowledges no streaming';
		$ua->delete_node($id);
	    }
	}
    }
}
done_testing;




( run in 0.250 second using v1.01-cache-2.11-cpan-4d50c553e7e )