AI-PredictionClient

 view release on metacpan or  search on metacpan

lib/AI/PredictionClient/CPP/PredictionGrpcCpp.pm  view on Meta::CPAN

## no critic
package AI::PredictionClient::CPP::PredictionGrpcCpp;
$AI::PredictionClient::CPP::PredictionGrpcCpp::VERSION = '0.05';

# ABSTRACT: The C++ interface to gRPC and Protocol Buffers

use Cwd;
use Alien::Google::GRPC;
use AI::PredictionClient::Alien::TensorFlowServingProtos;
use Inline
  CPP => 'DATA',
  with => ['Alien::Google::GRPC', 'AI::PredictionClient::Alien::TensorFlowServingProtos'],
  version => '0.05',
  name => 'AI::PredictionClient::CPP::PredictionGrpcCpp',
  TYPEMAPS => getcwd . '/blib/lib/AI/PredictionClient/CPP/Typemaps/more_typemaps_STL_String.txt',
  LIBS => '-ldl',
  ccflags => '-std=c++11 -pthread';

use 5.010;
use strict;
use warnings;

1;

=pod

=encoding UTF-8

=head1 NAME

AI::PredictionClient::CPP::PredictionGrpcCpp - The C++ interface to gRPC and Protocol Buffers

=head1 VERSION

version 0.05

=head1 AUTHOR

Tom Stall <stall@cpan.org>

=head1 COPYRIGHT AND LICENSE

This software is copyright (c) 2017 by Tom Stall.

This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.

=cut

__DATA__
__CPP__

#undef New
#undef Copy
#undef seed
#undef Zero
#undef Move
#define std__string std::string

#include <iostream>
#include <memory>
#include <string>

#include <grpc++/grpc++.h>
#include <google/protobuf/util/json_util.h>

#include "tensorflow_serving/apis/prediction_service.grpc.pb.h"
#include "tds/base64.pb.h"

using grpc::Channel;
using grpc::ClientContext;
using grpc::Status;
using tensorflow::serving::PredictRequest;
using tensorflow::serving::PredictResponse;
using tensorflow::serving::PredictionService;

class PredictionClient {
public:
  PredictionClient(std::string server_port);
  std::string callPredict(std::string serialized_request_object);

private:
  std::unique_ptr<PredictionService::Stub> stub_;
  std::string to_base64(std::string text);
};

PredictionClient::PredictionClient(std::string server_port)



( run in 1.259 second using v1.01-cache-2.11-cpan-39bf76dae61 )