1
0
mirror of https://github.com/pgbackrest/pgbackrest.git synced 2025-03-03 14:52:21 +02:00

Convert ProtocolParallelJobState enum to StringId.

Allows removal of protocolParallelJobToConstZ(), which was used only for debugging.
This commit is contained in:
David Steele 2021-04-28 11:43:08 -04:00
parent 85fc3da4c3
commit bd68ed63ba
4 changed files with 11 additions and 33 deletions

View File

@ -93,6 +93,7 @@
<commit subject="Update CipherType/CipherMode to StringId.">
<github-pull-request id="1384"/>
</commit>
<commit subject="Convert ProtocolParallelJobState enum to StringId."/>
<release-item-contributor-list>
<release-item-reviewer id="cynthia.shang"/>

View File

@ -277,6 +277,6 @@ String *
protocolParallelToLog(const ProtocolParallel *this)
{
return strNewFmt(
"{state: %s, clientTotal: %u, jobTotal: %u}", protocolParallelJobToConstZ(this->state), lstSize(this->clientList),
"{state: %s, clientTotal: %u, jobTotal: %u}", strZ(strIdToStr(this->state)), lstSize(this->clientList),
lstSize(this->jobList));
}

View File

@ -117,7 +117,7 @@ protocolParallelJobStateSet(ProtocolParallelJob *this, ProtocolParallelJobState
{
FUNCTION_LOG_BEGIN(logLevelTrace);
FUNCTION_LOG_PARAM(PROTOCOL_PARALLEL_JOB, this);
FUNCTION_LOG_PARAM(ENUM, state);
FUNCTION_LOG_PARAM(STRING_ID, state);
FUNCTION_LOG_END();
ASSERT(this != NULL);
@ -129,43 +129,19 @@ protocolParallelJobStateSet(ProtocolParallelJob *this, ProtocolParallelJobState
else
{
THROW_FMT(
AssertError, "invalid state transition from '%s' to '%s'", protocolParallelJobToConstZ(protocolParallelJobState(this)),
protocolParallelJobToConstZ(state));
AssertError, "invalid state transition from '%s' to '%s'", strZ(strIdToStr(protocolParallelJobState(this))),
strZ(strIdToStr(state)));
}
FUNCTION_LOG_RETURN_VOID();
}
/**********************************************************************************************************************************/
const char *
protocolParallelJobToConstZ(ProtocolParallelJobState state)
{
const char *result = NULL;
switch (state)
{
case protocolParallelJobStatePending:
result = "pending";
break;
case protocolParallelJobStateRunning:
result = "running";
break;
case protocolParallelJobStateDone:
result = "done";
break;
}
return result;
}
String *
protocolParallelJobToLog(const ProtocolParallelJob *this)
{
return strNewFmt(
"{state: %s, key: %s, command: %s, code: %d, message: %s, result: %s}",
protocolParallelJobToConstZ(protocolParallelJobState(this)), strZ(varToLog(protocolParallelJobKey(this))),
strZ(strIdToStr(protocolParallelJobState(this))), strZ(varToLog(protocolParallelJobKey(this))),
strZ(protocolCommandToLog(protocolParallelJobCommand(this))), protocolParallelJobErrorCode(this),
strZ(strToLog(protocolParallelJobErrorMessage(this))), strZ(varToLog(protocolParallelJobResult(this))));
}

View File

@ -4,6 +4,8 @@ Protocol Parallel Job
#ifndef PROTOCOL_PARALLEL_JOB_H
#define PROTOCOL_PARALLEL_JOB_H
#include "common/type/stringId.h"
/***********************************************************************************************************************************
Object type
***********************************************************************************************************************************/
@ -14,9 +16,9 @@ Job state enum
***********************************************************************************************************************************/
typedef enum
{
protocolParallelJobStatePending,
protocolParallelJobStateRunning,
protocolParallelJobStateDone,
protocolParallelJobStatePending = STRID5("pending", 0x1dc9238b00),
protocolParallelJobStateRunning = STRID5("running", 0x1dc973ab20),
protocolParallelJobStateDone = STRID5("done", 0x2b9e40),
} ProtocolParallelJobState;
#include "common/time.h"
@ -121,7 +123,6 @@ protocolParallelJobFree(ProtocolParallelJob *const this)
/***********************************************************************************************************************************
Macros for function logging
***********************************************************************************************************************************/
const char *protocolParallelJobToConstZ(ProtocolParallelJobState state);
String *protocolParallelJobToLog(const ProtocolParallelJob *this);
#define FUNCTION_LOG_PROTOCOL_PARALLEL_JOB_TYPE \