exchange

Base system with REST service to issue digital coins, run by the payment service provider
Log | Files | Refs | Submodules | README | LICENSE

update_shard_progress.h (2429B)


      1 /*
      2    This file is part of TALER
      3    Copyright (C) 2022, 2026 Taler Systems SA
      4 
      5    TALER is free software; you can redistribute it and/or modify it under the
      6    terms of the GNU General Public License as published by the Free Software
      7    Foundation; either version 3, or (at your option) any later version.
      8 
      9    TALER is distributed in the hope that it will be useful, but WITHOUT ANY
     10    WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
     11    A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
     12 
     13    You should have received a copy of the GNU General Public License along with
     14    TALER; see the file COPYING.  If not, see <http://www.gnu.org/licenses/>
     15  */
     16 /**
     17  * @file src/include/exchange-database/update_shard_progress.h
     18  * @brief implementation of the update_shard_progress function for Postgres
     19  * @author Christian Grothoff
     20  */
     21 #ifndef EXCHANGE_DATABASE_UPDATE_SHARD_PROGRESS_H
     22 #define EXCHANGE_DATABASE_UPDATE_SHARD_PROGRESS_H
     23 
     24 #include "exchangedb_lib.h"
     25 
     26 
     27 /**
     28  * Record how far a worker has come within a shard, and renew its lease on
     29  * that shard.  The shard is marked completed if @a progress_row reached
     30  * @a end_row.
     31  *
     32  * Call this from within the same transaction that persists the work being
     33  * reported.  That is the point of the function: the progress marker and the
     34  * work it describes have to become visible together, or a crash in between
     35  * leaves the two disagreeing.
     36  *
     37  * Progress only ever moves forward.  A second worker that grabbed the same
     38  * shard (because our lease ran out while we were still going) therefore
     39  * cannot rewind what we already recorded.
     40  *
     41  * @param pg the database context
     42  * @param job_name name of the job the shard belongs to
     43  * @param start_row inclusive start row of the shard
     44  * @param end_row exclusive end row of the shard
     45  * @param progress_row row up to which (exclusive) the work is done and
     46  *          committed; pass @a end_row to complete the shard
     47  * @param lease for how much longer we intend to hold the shard
     48  * @return transaction status code, #GNUNET_DB_STATUS_SUCCESS_NO_RESULTS if
     49  *          the shard is not in the table (someone else finished it)
     50  */
     51 enum GNUNET_DB_QueryStatus
     52 TALER_EXCHANGEDB_update_shard_progress (
     53   struct TALER_EXCHANGEDB_PostgresContext *pg,
     54   const char *job_name,
     55   uint64_t start_row,
     56   uint64_t end_row,
     57   uint64_t progress_row,
     58   struct GNUNET_TIME_Relative lease);
     59 
     60 #endif