Annotation of parser3/src/types/pa_vamqp.h, revision 1.3

1.1       moko        1: /** @file
                      2:        Parser: @b amqp class decls.
                      3: 
1.2       moko        4:        Copyright (c) 2001-2026 Art. Lebedev Studio (https://www.artlebedev.com)
1.1       moko        5:        Authors: Konstantin Morshnev <moko@design.ru>
                      6: */
                      7: 
                      8: #ifndef PA_VAMQP_H
                      9: #define PA_VAMQP_H
                     10: 
1.3     ! moko       11: #define IDENT_PA_VAMQP_H "$Id: pa_vamqp.h,v 1.2 2026/04/25 13:38:46 moko Exp $"
1.1       moko       12: 
                     13: #include "classes.h"
                     14: #include "pa_vstateless_object.h"
1.3     ! moko       15: #include "pa_common.h"
1.1       moko       16: 
                     17: #ifdef WITH_AMQP
                     18: #include <amqp.h>
                     19: #endif
                     20: 
                     21: // defines
                     22: #define VAMQP_TYPE "amqp"
                     23: 
                     24: // externs
                     25: extern Methoded *amqp_class;
                     26: 
                     27: class VAmqp: public VStateless_object {
                     28: public:
                     29:        // value
                     30:        override const char* type() const { return VAMQP_TYPE; }
                     31:        override VStateless_class *get_class() { return amqp_class; }
                     32: 
                     33: #ifdef WITH_AMQP
                     34: public: // usage
1.3     ! moko       35: 
        !            36:        // ALIVE: usable right now
        !            37:        // CHANNEL_DEAD: last operation got a channel-level error - reopening the channel (same connection) is required
        !            38:        // CONNECTION_DEAD: last operation got a connection-level error - a full reconnect is required
        !            39:        enum ConnState { ALIVE, CHANNEL_DEAD, CONNECTION_DEAD };
        !            40: 
        !            41:        VAmqp(): fconnection(0), fchannel(0), fstate(CONNECTION_DEAD), fcreate_options(0), freconnect_interval(0) {}
1.1       moko       42:        ~VAmqp() {}
                     43: 
                     44:        amqp_connection_state_t fconnection;
                     45:        int fchannel;
                     46:        bool fstop;
1.3     ! moko       47:        ConnState fstate;
        !            48:        HashStringValue* fcreate_options;
        !            49:        int freconnect_interval; // 0 = auto-reconnect disabled, N>0 = enabled, sleeps N sec before each attempt
        !            50: 
        !            51:        void ensure_connected();
1.1       moko       52: 
                     53:        amqp_connection_state_t connection() {
                     54:                if(!fconnection)
                     55:                        throw Exception(PARSER_RUNTIME, 0, "using uninitialized amqp object");
1.3     ! moko       56:                ensure_connected();
1.1       moko       57:                return fconnection;
                     58:        }
                     59: 
                     60:        int channel() {
                     61:                if(!fchannel)
                     62:                        throw Exception(PARSER_RUNTIME, 0, "using uninitialized amqp object channel");
1.3     ! moko       63:                ensure_connected();
1.1       moko       64:                return fchannel;
                     65:        }
                     66: 
                     67: #endif // WITH_AMQP
                     68: };
                     69: 
                     70: #endif
                     71: 
                     72: 

E-mail: