Skip to content

Commit 0729afb

Browse files
committed
docs(fuel-streams-core): Fix code example
1 parent d9b565a commit 0729afb

File tree

1 file changed

+9
-33
lines changed

1 file changed

+9
-33
lines changed

crates/core/README.md

Lines changed: 9 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ use fuel_streams_core::prelude::*;
120120
use fuel_streams_domains::infra::*;
121121
use fuel_web_utils::api_key::*;
122122
use fuel_message_broker::*;
123+
use fuel_streams_subject::subject::SubjectPayload;
123124
use futures::StreamExt;
124125
use std::sync::Arc;
125126
@@ -133,10 +134,14 @@ async fn main() -> anyhow::Result<()> {
133134
let fuel_streams = FuelStreams::new(&broker, &db).await;
134135
135136
// 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+
);
140145
141146
// Subscribe using the API key role for authentication
142147
let api_key_role = ApiKeyRole::default();
@@ -156,35 +161,6 @@ async fn main() -> anyhow::Result<()> {
156161
}
157162
```
158163

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-
188164
## 🔧 DeliverPolicy Options
189165

190166
The `DeliverPolicy` enum provides control over how messages are delivered in subscriptions:

0 commit comments

Comments
 (0)