@@ -120,6 +120,7 @@ use fuel_streams_core::prelude::*;
120
120
use fuel_streams_domains::infra::*;
121
121
use fuel_web_utils::api_key::*;
122
122
use fuel_message_broker::*;
123
+ use fuel_streams_subject::subject::SubjectPayload;
123
124
use futures::StreamExt;
124
125
use std::sync::Arc;
125
126
@@ -133,10 +134,14 @@ async fn main() -> anyhow::Result<()> {
133
134
let fuel_streams = FuelStreams::new(&broker, &db).await;
134
135
135
136
// Create a subscription with dynamic subject
136
- let subscription = Subscription {
137
- payload: TransactionsSubject::new().into(),
138
- deliver_policy: DeliverPolicy::New,
139
- };
137
+ // Use MockApiKey for testing purposes
138
+ let api_key = MockApiKey::builder(1.into()).into_inner();
139
+ let subject_payload = TransactionsSubject::new().into();
140
+ let subscription = Subscription::new(
141
+ &api_key,
142
+ &DeliverPolicy::New,
143
+ &subject_payload
144
+ );
140
145
141
146
// Subscribe using the API key role for authentication
142
147
let api_key_role = ApiKeyRole::default();
@@ -156,35 +161,6 @@ async fn main() -> anyhow::Result<()> {
156
161
}
157
162
```
158
163
159
- ### Publishing Data
160
-
161
- ``` rust,no_run
162
- use fuel_streams_core::prelude::*;
163
- use fuel_streams_domains::infra::*;
164
- use fuel_message_broker::*;
165
- use std::sync::Arc;
166
-
167
- #[tokio::main]
168
- async fn main() -> anyhow::Result<()> {
169
- // Setup connections
170
- let db = Arc::new(Db::new(DbConnectionOpts::default()).await?);
171
- let broker = Arc::new(NatsMessageBroker::setup("nats://localhost:4222", None).await?);
172
-
173
- // Create specific stream for blocks
174
- let block_stream = Stream::<Block>::get_or_init(&broker, &db).await;
175
-
176
- // Create data to publish
177
- let block_data = Block::default(); // Your block data here
178
- let response = StreamResponse::new(block_data);
179
-
180
- // Publish to the stream
181
- let subject = "blocks.100.hash";
182
- block_stream.publish(subject, &Arc::new(response)).await?;
183
-
184
- Ok(())
185
- }
186
- ```
187
-
188
164
## 🔧 DeliverPolicy Options
189
165
190
166
The ` DeliverPolicy ` enum provides control over how messages are delivered in subscriptions:
0 commit comments