-
Notifications
You must be signed in to change notification settings - Fork 1
feat: Update readme #26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 4 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
8d017e1
feat: Update readme
dotKuro 4ad0463
chore: Add examples
dotKuro ada4e89
Merge branch 'main' into update-readme
dotKuro 3808c50
chore: add missing new line
dotKuro 526b367
chore: add testcontainer to examples
dotKuro 973277e
Merge branch 'main' into update-readme
dotKuro f3bd46e
feat: Add seperate EventMissingStrategy for observing events
dotKuro 4b2a6e0
fix: Fix typos
dotKuro File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
doc-valid-idents = ["EventSourcingDB", "EventQL", "CloudEvents", ".."] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
use eventsourcingdb::client::Client; | ||
use futures::StreamExt; | ||
use url::Url; | ||
|
||
#[tokio::main] | ||
async fn main() { | ||
let base_url: Url = "localhost:3000".parse().unwrap(); | ||
let api_token = "secret"; | ||
let client = Client::new(base_url, api_token); | ||
|
||
let result = client.list_event_types().await; | ||
|
||
match result { | ||
Err(err) => panic!("{}", err), | ||
Ok(mut event_types) => { | ||
while let Some(Ok(event_type)) = event_types.next().await { | ||
println!("{:?}", event_type) | ||
} | ||
} | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
use eventsourcingdb::client::Client; | ||
use futures::StreamExt; | ||
use url::Url; | ||
|
||
#[tokio::main] | ||
async fn main() { | ||
let base_url: Url = "localhost:3000".parse().unwrap(); | ||
let api_token = "secret"; | ||
let client = Client::new(base_url, api_token); | ||
|
||
let result = client.list_subjects(Some("/")).await; | ||
|
||
match result { | ||
Err(err) => panic!("{}", err), | ||
Ok(mut subjects) => { | ||
while let Some(Ok(subject)) = subjects.next().await { | ||
println!("{:?}", subject) | ||
} | ||
} | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
use eventsourcingdb::client::{Client, request_options::ObserveEventsRequestOptions}; | ||
use futures::StreamExt; | ||
use url::Url; | ||
|
||
#[tokio::main] | ||
async fn main() { | ||
let base_url: Url = "localhost:3000".parse().unwrap(); | ||
let api_token = "secret"; | ||
let client = Client::new(base_url, api_token); | ||
|
||
let result = client | ||
.observe_events( | ||
"/books/42", | ||
Some(ObserveEventsRequestOptions { | ||
recursive: false, | ||
from_latest_event: None, | ||
lower_bound: None, | ||
}), | ||
) | ||
.await; | ||
|
||
match result { | ||
Err(err) => panic!("{}", err), | ||
Ok(mut stream) => { | ||
while let Some(Ok(event)) = stream.next().await { | ||
println!("{:?}", event) | ||
} | ||
} | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
use eventsourcingdb::client::Client; | ||
use url::Url; | ||
|
||
#[tokio::main] | ||
async fn main() { | ||
let base_url: Url = "localhost:3000".parse().unwrap(); | ||
let api_token = "secret"; | ||
let client = Client::new(base_url, api_token); | ||
|
||
let result = client.ping().await; | ||
if let Err(err) = result { | ||
// handle error | ||
panic!("{}", err) | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
use eventsourcingdb::client::{Client, request_options::ReadEventsRequestOptions}; | ||
use futures::StreamExt; | ||
use url::Url; | ||
|
||
#[tokio::main] | ||
async fn main() { | ||
let base_url: Url = "localhost:3000".parse().unwrap(); | ||
let api_token = "secret"; | ||
let client = Client::new(base_url, api_token); | ||
|
||
let result = client | ||
.read_events( | ||
"/books/42", | ||
Some(ReadEventsRequestOptions { | ||
recursive: false, | ||
from_latest_event: None, | ||
order: None, | ||
lower_bound: None, | ||
upper_bound: None, | ||
}), | ||
) | ||
.await; | ||
|
||
match result { | ||
Err(err) => panic!("{}", err), | ||
Ok(mut stream) => { | ||
while let Some(Ok(event)) = stream.next().await { | ||
println!("{:?}", event) | ||
} | ||
} | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
use eventsourcingdb::client::Client; | ||
use serde_json::json; | ||
use url::Url; | ||
|
||
#[tokio::main] | ||
async fn main() { | ||
let base_url: Url = "localhost:3000".parse().unwrap(); | ||
let api_token = "secret"; | ||
let client = Client::new(base_url, api_token); | ||
|
||
let result = client | ||
.register_event_schema( | ||
"io.eventsourcingdb.library.book-acquired", | ||
&json!({ | ||
"type": "object", | ||
"properties": { | ||
"title": { "type": "string" }, | ||
"author": { "type": "string" }, | ||
"isbn": { "type": "string" }, | ||
}, | ||
"required": [ | ||
"title", | ||
"author", | ||
"isbn", | ||
], | ||
"additionalProperties": false, | ||
}), | ||
) | ||
.await; | ||
|
||
if let Err(err) = result { | ||
panic!("{}", err) | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
use eventsourcingdb::client::Client; | ||
use futures::StreamExt; | ||
use url::Url; | ||
|
||
#[tokio::main] | ||
async fn main() { | ||
let base_url: Url = "localhost:3000".parse().unwrap(); | ||
let api_token = "secret"; | ||
let client = Client::new(base_url, api_token); | ||
|
||
let result = client | ||
.run_eventql_query("FROM e IN events PROJECT INTO e") | ||
.await; | ||
|
||
match result { | ||
Err(err) => panic!("{}", err), | ||
Ok(mut stream) => { | ||
while let Some(Ok(row)) = stream.next().await { | ||
println!("{:?}", row) | ||
} | ||
} | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
use eventsourcingdb::client::Client; | ||
use url::Url; | ||
|
||
#[tokio::main] | ||
async fn main() { | ||
let base_url: Url = "localhost:3000".parse().unwrap(); | ||
let api_token = "secret"; | ||
let client = Client::new(base_url, api_token); | ||
|
||
let result = client.verify_api_token().await; | ||
if let Err(err) = result { | ||
// handle error | ||
panic!("{}", err) | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
use eventsourcingdb::{client::Client, event::EventCandidate}; | ||
use serde_json::json; | ||
use url::Url; | ||
|
||
#[tokio::main] | ||
async fn main() { | ||
let base_url: Url = "localhost:3000".parse().unwrap(); | ||
let api_token = "secret"; | ||
let client = Client::new(base_url, api_token); | ||
|
||
let event = EventCandidate::builder() | ||
.source("https://library.eventsourcingdb.io".to_string()) | ||
.subject("/books/42".to_string()) | ||
.ty("io.eventsourcingdb.library.book-acquired") | ||
.data(json!({ | ||
"title": "2001 - A Space Odyssey", | ||
"author": "Arthur C. Clarke", | ||
"isbn": "978-0756906788", | ||
})) | ||
.build(); | ||
|
||
let result = client.write_events(vec![event.clone()], vec![]).await; | ||
match result { | ||
Ok(written_events) => println!("{:?}", written_events), | ||
Err(err) => panic!("{}", err), | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.