-
Notifications
You must be signed in to change notification settings - Fork 97
Expand file tree
/
Copy pathPythonWrapper.h
More file actions
167 lines (140 loc) · 6.37 KB
/
PythonWrapper.h
File metadata and controls
167 lines (140 loc) · 6.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "CCommon.h"
#include "CMessage.h"
#include "CMessageExt.h"
#include "CSendResult.h"
#include "CProducer.h"
#include "CPushConsumer.h"
#include "CPullConsumer.h"
#include "CMQException.h"
#include <boost/python.hpp>
using namespace boost::python;
typedef struct _PySendResult_ {
CSendStatus sendStatus;
char msgId[MAX_MESSAGE_ID_LENGTH];
long long offset;
const char *GetMsgId() {
return (const char *) msgId;
}
} PySendResult;
typedef struct _PyMQException_ {
int error;
int line;
char file[MAX_EXEPTION_FILE_LENGTH];
char msg[MAX_EXEPTION_MSG_LENGTH];
char type[MAX_EXEPTION_TYPE_LENGTH];
const char *GetFile() {
return (const char *) file;
}
const char *GetMsg() {
return (const char *) msg;
}
const char *GetType() {
return (const char *) type;
}
} PyMQException;
typedef struct _PyMessageExt_ {
CMessageExt *pMessageExt;
} PyMessageExt;
typedef struct _PyUserData_ {
PyObject *pyObject;
void *pData;
} PyUserData;
typedef struct _PyCallback_ {
PyObject *successCallback;
PyObject *exceptionCallback;
} PyCallback;
#define PYTHON_CLIENT_VERSION "1.2.0"
#define PYCLI_BUILD_DATE "04-12-2018"
#ifdef __cplusplus
extern "C" {
#endif
//message
void *PyCreateMessage(const char *topic);
int PyDestroyMessage(void *msg);
int PySetMessageTopic(void *msg, const char *topic);
int PySetMessageTags(void *msg, const char *tags);
int PySetMessageKeys(void *msg, const char *keys);
int PySetMessageBody(void *msg, const char *body);
int PySetByteMessageBody(void *msg, const char *body, int len);
int PySetMessageProperty(void *msg, const char *key, const char *value);
int PySetMessageDelayTimeLevel(void *msg, int level);
//messageExt
const char *PyGetMessageTopic(PyMessageExt msgExt);
const char *PyGetMessageTags(PyMessageExt msgExt);
const char *PyGetMessageKeys(PyMessageExt msgExt);
const char *PyGetMessageBody(PyMessageExt msgExt);
const char *PyGetMessageProperty(PyMessageExt msgExt, const char *key);
const char *PyGetMessageId(PyMessageExt msgExt);
//producer
void *PyCreateProducer(const char *groupId);
void *PyCreateOrderProducer(const char *groupId);
CTransactionStatus PyLocalTransactionCheckerCallback(CProducer *producer, CMessageExt *msg, void *data);
CTransactionStatus PyLocalTransactionExecuteCallback(CProducer *producer, CMessage *msg, void *data);
void *PyCreateTransactionProducer(const char *groupId, PyObject *localTransactionCheckerCallback);
int PyDestroyProducer(void *producer);
int PyDestroyTransactionProducer(void *producer);
int PyStartProducer(void *producer);
int PyShutdownProducer(void *producer);
int PySetProducerNameServerAddress(void *producer, const char *namesrv);
int PySetProducerNameServerDomain(void *producer, const char *domain);
int PySetProducerInstanceName(void *producer, const char *instanceName);
int PySetProducerSessionCredentials(void *producer, const char *accessKey, const char *secretKey, const char *channel);
int PySetProducerCompressLevel(void *producer, int level);
int PySetProducerMaxMessageSize(void *producer, int size);
int PySetProducerLogPath(void *producer, const char *logPath);
int PySetProducerLogFileNumAndSize(void *producer, int fileNum, long fileSize);
int PySetProducerLogLevel(void *producer, CLogLevel level);
int PySetProducerSendMsgTimeout(void *producer, int timeout);
PySendResult PySendMessageSync(void *producer, void *msg);
int PySendMessageOneway(void *producer, void *msg);
void PySendSuccessCallback(CSendResult result, CMessage *msg, void *pyCallback);
void PySendExceptionCallback(CMQException e, CMessage *msg, void *pyCallback);
int PySendMessageAsync(void *producer, void *msg, PyObject *sendSuccessCallback, PyObject *sendExceptionCallback);
PySendResult PySendMessageOrderly(void *producer, void *msg, int autoRetryTimes, void *args, PyObject *queueSelector);
PySendResult PySendMessageOrderlyByShardingKey(void *producer, void *msg, const char *shardingKey);
PySendResult PySendMessageInTransaction(void *producer , void *msg, PyObject *localTransactionExecuteCallback , void *args);
int PyOrderlyCallbackInner(int size, CMessage *msg, void *args);
//sendResult
const char *PyGetSendResultMsgID(CSendResult &sendResult);
//consumer
void *PyCreatePushConsumer(const char *groupId);
int PyDestroyPushConsumer(void *consumer);
int PyStartPushConsumer(void *consumer);
int PyShutdownPushConsumer(void *consumer);
int PySetPushConsumerNameServerAddress(void *consumer, const char *namesrv);
int PySetPushConsumerNameServerDomain(void *consumer, const char *domain);
int PySubscribe(void *consumer, const char *topic, const char *expression);
int PyRegisterMessageCallback(void *consumer, PyObject *pCallback, object args);
int PyRegisterMessageCallbackOrderly(void *consumer, PyObject *pCallback, object args);
int PythonMessageCallBackInner(CPushConsumer *consumer, CMessageExt *msg);
int PySetPushConsumerThreadCount(void *consumer, int threadCount);
int PySetPushConsumerMessageBatchMaxSize(void *consumer, int batchSize);
int PySetPushConsumerInstanceName(void *consumer, const char *instanceName);
int PySetPushConsumerSessionCredentials(void *consumer, const char *accessKey, const char *secretKey, const char *channel);
int PySetPushConsumerMessageModel(void *consumer, CMessageModel messageModel);
int PySetPushConsumerLogPath(void *consumer, const char *logPath);
int PySetPushConsumerLogFileNumAndSize(void *consumer, int fileNum, long fileSize);
int PySetPushConsumerLogLevel(void *consumer, CLogLevel level);
//push consumer
int PySetPullConsumerNameServerDomain(void *consumer, const char *domain);
//version
const char *PyGetVersion();
#ifdef __cplusplus
};
#endif