Skip to content

Commit

Permalink
Rename opCall to constructMessage
Browse files Browse the repository at this point in the history
To be more clear, methods that are constructing
message are now named constructMessage.
  • Loading branch information
Burgos committed Feb 1, 2017
1 parent ebf3220 commit 137bef1
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 17 deletions.
16 changes: 8 additions & 8 deletions src/postgres/connection.d
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ struct Connection
{
if (auth_msg.format == AuthenticationMessage.AuthFormat.MD5PASS)
{
this.send(Md5PasswordMessage(this.payload_appender, this.username,
this.send(Md5PasswordMessage.constructMessage(this.payload_appender, this.username,
this.password, auth_msg.salt.md5_salt));
}
else
Expand Down Expand Up @@ -232,7 +232,7 @@ struct Connection
ReadyForQueryMessage;

// TODO: make receiveOne static
this.send(QueryMessage(this.payload_appender, query_string));
this.send(QueryMessage.constructMessage(this.payload_appender, query_string));
auto response = msg.receiveOne(this);

if (auto rows = response.peek!(RowDescriptionMessage))
Expand Down Expand Up @@ -301,7 +301,7 @@ struct Connection
ReadyForQueryMessage;

// TODO: make receiveOne static
this.send(QueryMessage(this.payload_appender, query_string));
this.send(QueryMessage.constructMessage(this.payload_appender, query_string));
this.set.response = msg.receiveOne(this);

if (auto rows = this.set.response.peek!(RowDescriptionMessage))
Expand Down Expand Up @@ -387,11 +387,11 @@ struct Connection
SyncMessage sync;
parsemsg.query_string = query_string;

this.send(ParseMessage(this.payload_appender, parsemsg));
this.send(BindMessage(this.payload_appender, bindmsg));
this.send(DescribeMessage(this.payload_appender, describemsg));
this.send(ExecuteMessage(this.payload_appender, execmsg));
this.send(SyncMessage(this.payload_appender, sync));
this.send(ParseMessage.constructMessage(this.payload_appender, parsemsg));
this.send(BindMessage.constructMessage(this.payload_appender, bindmsg));
this.send(DescribeMessage.constructMessage(this.payload_appender, describemsg));
this.send(ExecuteMessage.constructMessage(this.payload_appender, execmsg));
this.send(SyncMessage.constructMessage(this.payload_appender, sync));

this.set.response = msg.receiveOne(this);
enforce(this.set.response.peek!(ParseCompleteMessage),
Expand Down
21 changes: 12 additions & 9 deletions src/postgres/message.d
Original file line number Diff line number Diff line change
Expand Up @@ -308,12 +308,15 @@ struct Md5PasswordMessage

/// Constructs a MD5 password responde message
/// using the given password and salt
static ubyte[] opCall(ref Appender!(ubyte[]) app, string username, string password, int salt)
static ubyte[] constructMessage(ref Appender!(ubyte[]) app,
string username, string password, int salt)
{
return Md5PasswordMessage(app, username, password, (cast(ubyte*)&salt)[0..int.sizeof]);
return Md5PasswordMessage.constructMessage(app, username, password,
(cast(ubyte*)&salt)[0..int.sizeof]);
}

static ubyte[] opCall(ref Appender!(ubyte[]) app, string username, string password, ubyte[] salt)
static ubyte[] constructMessage(ref Appender!(ubyte[]) app,
string username, string password, ubyte[] salt)
{
ubyte[32 + 4] hash_buf; // md5+password string

Expand Down Expand Up @@ -558,7 +561,7 @@ struct QueryMessage

/// Constructs a query message using the
/// query string
static ubyte[] opCall(ref Appender!(ubyte[]) app, string query)
static ubyte[] constructMessage(ref Appender!(ubyte[]) app, string query)
{
return Message.constructMessage(app, Tag, query);
}
Expand Down Expand Up @@ -824,7 +827,7 @@ struct ParseMessage
public TypeOID[] data_types = [TypeOID.NOT_SPECIFIED];

/// Constructs a Parse message
static ubyte[] opCall(ref Appender!(ubyte[]) app, ParseMessage msg)
static ubyte[] constructMessage(ref Appender!(ubyte[]) app, ParseMessage msg)
{
return Message.constructMessage(app, Tag,
msg.prepared_statement_name,
Expand Down Expand Up @@ -887,7 +890,7 @@ struct BindMessage
public FormatCodes[] result_format_codes;

/// Constructs a Bind message
static ubyte[] opCall(ref Appender!(ubyte[]) app, BindMessage msg)
static ubyte[] constructMessage(ref Appender!(ubyte[]) app, BindMessage msg)
{
return Message.constructMessage(app, Tag,
msg.dest_portal_name,
Expand Down Expand Up @@ -1008,7 +1011,7 @@ struct DescribeMessage


/// Constructs a Bind message
static ubyte[] opCall(ref Appender!(ubyte[]) app, DescribeMessage msg)
static ubyte[] constructMessage(ref Appender!(ubyte[]) app, DescribeMessage msg)
{
return Message.constructMessage(app, Tag,
msg.type,
Expand All @@ -1034,7 +1037,7 @@ struct ExecuteMessage


/// Constructs a Bind message
static ubyte[] opCall(ref Appender!(ubyte[]) app, ExecuteMessage msg)
static ubyte[] constructMessage(ref Appender!(ubyte[]) app, ExecuteMessage msg)
{
return Message.constructMessage(app, Tag,
msg.portal_name,
Expand Down Expand Up @@ -1083,7 +1086,7 @@ struct SyncMessage
enum origin = Origin.FRONTEND;

/// Constructs a Sync message
static ubyte[] opCall(ref Appender!(ubyte[]) app, SyncMessage msg)
static ubyte[] constructMessage(ref Appender!(ubyte[]) app, SyncMessage msg)
{
return Message.constructMessage(app, Tag);
}
Expand Down

0 comments on commit 137bef1

Please sign in to comment.