Skip to content

Commit

Permalink
revise tateyama/proto/endpoint/request.proto
Browse files Browse the repository at this point in the history
  • Loading branch information
t-horikawa committed Jan 19, 2024
1 parent 118dd3d commit 4258a26
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 14 deletions.
45 changes: 31 additions & 14 deletions src/tateyama/proto/endpoint/request.proto
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ option java_multiple_files = false;
option java_package = "com.tsurugidb.endpoint.proto";
option java_outer_classname = "EndpointRequest";

import "tateyama/proto/auth/request.proto";

// the request message to endpoint pseudo service.
message Request {
// service message version (major)
Expand All @@ -29,11 +27,14 @@ message Request {

// handshake operation.
message Handshake {
// the auth info.
auth.request.AuthInfo auth_info = 1;

// the client information.
ClientInformation client_information = 2;
ClientInformation client_information = 1;

// reserved for system use
reserved 2 to 10;

// the wire information.
WireInformation wire_information = 11;
}

// client information
Expand All @@ -44,15 +45,31 @@ message ClientInformation {
// the application name.
string application_name = 2;

// the user name.
string user_name = 4;
// the credential.
Credential credential = 3;
}

// the connection information
string connection_information = 5;
// the credential
message Credential {
// FIXME (T.B.D.)
}

// reserved for future use
reserved 6 to 10;
// wire information
message WireInformation {
oneof wire_information {
IpcInformation ipc_information = 1;
StreamInformation stream_information = 2;
}

// the maximum concurrent result sets
uint64 maximum_concurrent_result_sets = 11;
// ipc information
message IpcInformation {
// the connection information
string connection_information = 1;
}

// stream information
message StreamInformation {
// the maximum concurrent result sets
uint64 maximum_concurrent_result_sets = 1;
}
}
10 changes: 10 additions & 0 deletions src/tateyama/transport/transport.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
#include <sstream>
#include <optional>
#include <exception>
#include <sys/types.h>
#include <unistd.h>

#include <tateyama/utils/protobuf_utils.h>
#include <tateyama/proto/framework/request.pb.h>
Expand Down Expand Up @@ -169,12 +171,20 @@ class transport {
std::optional<tateyama::proto::endpoint::response::Handshake> handshake() {
tateyama::proto::endpoint::request::ClientInformation information{};
information.set_application_name("tgctl");

tateyama::proto::endpoint::request::WireInformation wire_information{};
tateyama::proto::endpoint::request::WireInformation::IpcInformation ipc_information{};
ipc_information.set_connection_information(std::to_string(getpid()));
wire_information.set_allocated_ipc_information(&ipc_information);
tateyama::proto::endpoint::request::Handshake handshake{};
handshake.set_allocated_client_information(&information);
handshake.set_allocated_wire_information(&wire_information);
tateyama::proto::endpoint::request::Request request{};
request.set_allocated_handshake(&handshake);
auto response = send<tateyama::proto::endpoint::response::Handshake>(request);
request.release_handshake();
wire_information.release_ipc_information();
handshake.release_wire_information();
handshake.release_client_information();
return response;
}
Expand Down

0 comments on commit 4258a26

Please sign in to comment.