Movatterモバイル変換


[0]ホーム

URL:


Skip to main content
Kurrent Docs
or

Self-Guided Demo


KurrentDB Quickstart

This quickstart will guide you through getting started with KurrentDB using GitHub Codespaces.

Info

GitHub Codespaces provides an instant and preconfigured development environment in your browser for this quickstart. To learn more about Github Codespaces,click here.

Objectives

In this quickstart, you will:

  • Start a KurrentDB server using Docker in GitHub Codespaces.
  • Append an event to KurrentDB with sample code.
  • View the appended event using the Admin UI.
  • Read the appended event with sample code using the KurrentDB client.

Prerequisites

Before starting, ensure you have the following:

  • A GitHub account to use GitHub Codespaces.
  • Basic knowledge of one of the development languages/platforms below.
  • Familiarity with command-line operations.

Tips

If you have trouble with this quickstart, you can find more help in the"KurrentDB From Scratch" tutorial series on Kurrent Academy.

Step 1: Set up Your Codespace

  1. Choose one of the development languages/platforms below and click the Codespaces link:
Select >

  1. Log in to GitHub if required.

  2. Follow the instructions to create a new Codespace.

  3. Wait for your Codespace to build. This can take up to a few minutes.

  4. Once complete, you will see a welcome message in the terminal:

Hello!👋 Welcome to the EventStoreDB Getting Started Quickstart Guide.

Tips

For this quickstart, you can safely ignore and close any Codespaces notifications that appear on the bottom right of the page.

Step 2: Start the KurrentDB Server

  1. Once your Codespace is loaded, run the following command in the terminal to start the KurrentDB server:

    ./start_db.sh

    This is a custom script written for this quickstart to help start KurrentDB in Docker.

  2. You will see the following message printed in the terminal:

🚀 EventStoreDB Server has started!! 🚀URL to the EventStoreDB Admin UI 👉: https://XXXXXXXXX.XXX
(Optional) Learn more about how to start KurrentDB in Docker and thestart_db.sh script

Understanding How to Start KurrentDB Server in Docker and Howstart_db.sh Works

start_db.sh is a custom script written for the quickstart that will:

  • Check if Docker is currently running locally
  • Pull the KurrentDB server Docker container
  • Start the server in Docker
  • Print the KurrentDB Admin UI URL in the terminal

To see how to start the KurrentDB server in Docker, follow these steps

  1. Run the following command to openstart_db.sh:

    code ./start_db.sh

    Tips

    Alternatively, you can locate and open the file from the EXPLORER window found on the left side of Codespaces. You can find the path to the file in the command above.

  2. In step 3 of the script, review how KurrentDB is started with thedocker run command:

docker run                               # Start a new Docker container using the 'docker run' command     -d \                               # Run the container in detached mode (in the background)     --name esdb-node \                 # Assign the container a name ('esdb-node' in this case)     -p 2113:2113 \                     # Map port 2113 on the host to port 2113 in the Docker container. Required for the KurrentDB     eventstore/eventstore:24.10.1 \ # Specify the Docker image to use, in this case, the latest supported version of KurrentDB     --insecure \                       # Run KurrentDB in insecure mode, without authentication and SSL/TLS security (usually for development)     --run-projections=All \            # Enable all projections in KurrentDB, including system and user projections     --enable-atom-pub-over-http         # Enable the AtomPub API over HTTP. Required for the KurrentDB Admin UI
  1. Review other parts of the script if you wish.

  2. Feel free to modify and re-run the script in your Codespace.

Info

For more information about other KurrentDB parameters and settings,click here.

Info

To view the source code on Github, click the link below:

Select >

Step 3: Navigate to the KurrentDB Admin UI

  1. In Codespaces, copy the URL to KurrentDB Admin UI printed in the terminal from the last step.
  2. Open a new browser tab.
  3. In the address bar of the new tab, paste the URL and navigate to it.
  4. This will display the KurrentDB Admin UI.
  5. Keep the Admin UI open for the next steps.
KurrentDB Admin UI Dashboard
KurrentDB Admin UI Dashboard

Step 4: Install Required Package for Sample Code

  1. In Codespace, run the following command to install the KurrentDB client package. This will be used in the sample codes:
Select >

(Optional) Learn more about the KurrentDB client packages

Understanding Required Packages for KurrentDB Development

The KurrentDB client packages enable your code to connect to the database, append events, and read events from streams in the language/platform of your choice.

To understand what packages are installed, follow these steps:

  1. Run the following command to examine package dependencies:
Select >

Tips

Alternatively, you can locate and open the file from the EXPLORER window on the left of Codespaces. You can find the path to the file in the command above.

  1. Review the KurrentDB client packages listed as dependencies:
Select >

Note

The version of the KurrentDB client above may be outdated. For more information about the client,click here.

Info

To view the source code on GitHub, click the link below:

Select >

Step 5: Append an Event to KurrentDB

  1. In Codespaces, run this command to execute the sample. This appends an event to KurrentDB:
Select >

  1. You should see a confirmation for the event append, similar to this:
************************🎉 Congratulations, you have written an event!Stream: SampleStreamEvent Type: SampleEventTypeEvent Body: {"id":"1","importantData":"some value"}************************"
(Optional) Learn more about the sample code

Understanding How the Append Sample Works

To help you understand how events are appended to KurrentDB programmatically, you will explore the sample code used in this step.

The sample code demonstrates:

  • Establishing a Connection: Connect to KurrentDB using the client library.
  • Creating an Event: Create a new event with a specific type and data payload.
  • Appending the Event to a Stream: Append the new event to a specific stream.

To see how this works, follow these steps:

  1. Run the following command to open the sample code:
Select >

Tips

Alternatively, you can locate and open the file from the EXPLORER window on the left of Codespaces. You can find the path to the file in the command above.

  1. In step 1 of the code, review how the client connects to KurrentDB:
Select >

  1. In step 2 of the code, review how a new event is initiated:
Select >

  1. In step 3 of the code, review how the client appends the new event to KurrentDB:
Select >

  1. Feel free to modify and re-run the sample in your Codespace.

Info

To learn more about other KurrentDB client functions,click here.

Info

To view the source code on GitHub, click the link below:

Select >

Step 6: Verify the Appended Event in the Admin UI

  1. In the Admin UI, click theStream Browser link from the top navigation bar.

  2. UnderRecently Changed Streams, click theSampleStream link.

  3. Click on theJSON link in the rightmost column of the table.

  4. You should see the content of the appended event.

Step 7: Read the Event from KurrentDB Programmatically

  1. In Codespaces, run this command to execute the sample. This reads the event from KurrentDB:
Select >

  1. You should see the content of the appended event similar to this:
************************You have read an event!Stream: SampleStreamEvent Type: SampleEventTypeEvent Body: {"id":"1","importantData":"some value"}************************"
(Optional) Learn more about the sample code

Understanding How the Read Sample Works

You will explore the sample code used in this step to gain a deeper understanding of how events are read from KurrentDB programmatically. The sample code demonstrates the following:

  • Establishing a Connection: Illustrates how to connect to KurrentDB using the client library.
  • Reading Events from a Stream: Reads events from a specific stream.
  • Processing Retrieved Events: Iterates over the events retrieved from the stream.
  • Deserializing Event Data: Extracts and deserializes the event data from the retrieved events.
  • Displaying Event Information: Prints out the event details—such as the stream name, event type, and event body—to the console.
  1. Run the following command to open the sample code:
Select >

Tips

Alternatively, you can locate and open the file from the EXPLORER window on the left of Codespaces. You can find the path to the file in the command above.

  1. In step 1 of the code, review how the client connects to KurrentDB:
Select >

  1. In step 2 of the code, review how the client reads all the events from the stream:
Select >

  1. In step 3 of the code, review how the events are deserialized and printed:
Select >

  1. Feel free to modify and re-run the sample in your Codespace.

Info

To learn more about other KurrentDB client functions,click here.

Info

To view the source code on Github, click the link below:

Select >

Summary

In this quickstart, you:

  1. Started the KurrentDB server.
  2. Navigated to the Admin UI.
  3. Appended an event to KurrentDB.
  4. Verified the event in the Admin UI.
  5. Read the event from KurrentDB programmatically.

Feel free to experiment further by appending more events, reading them, or exploring the advanced features of KurrentDB.

Last Updated:

[8]ページ先頭

©2009-2025 Movatter.jp