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
167
168
169
170
171
use reqwest::{header::HeaderMap, Method};
#[derive(Debug, Clone)]
pub enum PublishRequestUrl {
Url(reqwest::Url),
Topic(String),
}
/// Options that Qstash allows to be used when publishing a message.
pub struct PublishOptions {
/// Optionally send along headers with the message.
/// These headers will be sent to your destination.
///
/// We highly recommend sending a `Content-Type` header along, as this will help your destination
/// server to understand the content of the message.
pub headers: Option<HeaderMap>,
/// Optionally delay the delivery of this message.
/// In seconds.
pub delay: Option<u32>,
/// Optionally set the absolute delay of this message.
/// This will override the delay option.
/// The message will not delivered until the specified time.
///
/// Unix timestamp in seconds.
pub not_before: Option<u32>,
/// Provide a unique id for deduplication. This id will be used to detect duplicate messages.
/// If a duplicate message is detected, the request will be accepted but not enqueued.
/// We store deduplication ids for 90 days. Afterwards it is possible that the message with the
/// same deduplication id is delivered again.
///
/// When scheduling a message, the deduplication happens before the schedule is created.
pub deduplication_id: Option<String>,
///
/// If true, the message content will get hashed and used as deduplication id.
/// If a duplicate message is detected, the request will be accepted but not enqueued.
///
/// The content based hash includes the following values:
/// - All headers, except Upstash-Authorization, this includes all headers you are sending.
/// - The entire raw request body The destination from the url path
///
/// We store deduplication ids for 90 days. Afterwards it is possible that the message with the
/// same deduplication id is delivered again.
///
/// When scheduling a message, the deduplication happens before the schedule is created.
pub content_based_deduplication: Option<bool>,
///
/// In case your destination server is unavaialble or returns a status code outside of the 200-299
/// range, we will retry the request after a certain amount of time.
///
/// Configure how many times you would like the delivery to be retried
///
/// @default The maximum retry quota associated with your account.
///
pub retries: Option<u32>,
///
/// Use a callback url to forward the response of your destination server to your callback url.
///
/// The callback url must be publicly accessible
///
/// @default None
///
pub callback: Option<String>,
///
///The method to use when sending a request to your API
///
///@default `POST`
///
pub method: Option<Method>,
}
#[derive(Debug, Clone)]
pub struct PublishRequest<T>
where
T: Into<reqwest::Body>,
{
pub url: PublishRequestUrl,
/// The message to send.
/// This can be anything, but please set the `Content-Type` header accordingly.
/// You can leave this empty if you want to send a message with no body.
pub body: Option<T>,
/// Optionally send along headers with the message.
/// These headers will be sent to your destination.
///
/// We highly recommend sending a `Content-Type` header along, as this will help your destination
/// server to understand the content of the message.
pub headers: Option<HeaderMap>,
/// Optionally delay the delivery of this message.
/// In seconds.
pub delay: Option<u32>,
/// Optionally set the absolute delay of this message.
/// This will override the delay option.
/// The message will not delivered until the specified time.
///
/// Unix timestamp in seconds.
pub not_before: Option<u32>,
/// Provide a unique id for deduplication. This id will be used to detect duplicate messages.
/// If a duplicate message is detected, the request will be accepted but not enqueued.
/// We store deduplication ids for 90 days. Afterwards it is possible that the message with the
/// same deduplication id is delivered again.
///
/// When scheduling a message, the deduplication happens before the schedule is created.
pub deduplication_id: Option<String>,
///
/// If true, the message content will get hashed and used as deduplication id.
/// If a duplicate message is detected, the request will be accepted but not enqueued.
///
/// The content based hash includes the following values:
/// - All headers, except Upstash-Authorization, this includes all headers you are sending.
/// - The entire raw request body The destination from the url path
///
/// We store deduplication ids for 90 days. Afterwards it is possible that the message with the
/// same deduplication id is delivered again.
///
/// When scheduling a message, the deduplication happens before the schedule is created.
pub content_based_deduplication: Option<bool>,
///
/// In case your destination server is unavaialble or returns a status code outside of the 200-299
/// range, we will retry the request after a certain amount of time.
///
/// Configure how many times you would like the delivery to be retried
///
/// @default The maximum retry quota associated with your account.
///
pub retries: Option<u32>,
///
/// Use a callback url to forward the response of your destination server to your callback url.
///
/// The callback url must be publicly accessible
///
/// @default None
///
pub callback: Option<String>,
///
///The method to use when sending a request to your API
///
///@default `POST`
///
pub method: Option<Method>,
}
impl<T: Into<reqwest::Body>> PublishRequest<T> {
pub fn new(url: PublishRequestUrl) -> Self {
Self {
url,
body: None,
headers: None,
delay: None,
not_before: None,
deduplication_id: None,
content_based_deduplication: None,
retries: None,
callback: None,
method: None,
}
}
}