Skip to content

Commit 77d42a4

Browse files
committed
first commit
0 parents  commit 77d42a4

9 files changed

+161
-0
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.venv/
388 KB
Binary file not shown.

InstructionsForRunningLocally.pdf

198 KB
Binary file not shown.

README.md

+77
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
# Welcome to the EventStoreDB's "From Scratch" series
2+
# <code style="color : green">Python edition</code>
3+
4+
Cook up your own tasty recipes by following the following examples in the "FromScratch" series:
5+
1. .NET
6+
2. Node.js
7+
3. Python
8+
4. Java
9+
10+
The **FromScratch** series provides practical path to learn a new framework. Follow this thorough set of instructions and example code and successsfully complete your initial project.
11+
12+
# Goals of the project
13+
14+
The Event Store Academy team (link to Academy when ready) wrote these with the following design goals.
15+
16+
1. Solve the "Doesn't run on my machine" problem by configuring and verifying success in GitHub codespaces
17+
2. Clearly provide and explain all dependencies
18+
3. Include instructions to configure locally, including setting up a development environment
19+
20+
The From Scracth cotent intends to provide EVERYTHING you need to get started in ONE place.
21+
22+
# Using this repo
23+
24+
### 1. Start with Codespaces
25+
26+
A fast path to successfully running this code is to utilize GitHub codespaces.
27+
28+
For more info on codespaces please visit https://github.com/features/codespaces.
29+
30+
At the time of writing this all GitHub users receive 60 hours/month of free access to codespaces for non-commercial use. As such, all you need to get started is a GitHub account.
31+
32+
Instructions for Running this code in Codespaces is available as a pdf here [Instructions For Running in Codespaces](./InstructionsForRunningInCodeSpaces.pdf)
33+
34+
### 2. Cloning this Repo and Running Locally on your computer
35+
36+
The steps needed to take this repository as is, and run locally are included as a pdf here.
37+
[Instructions For Running Locally](./InstructionsForRunningLocally.pdf)
38+
39+
The main difference between running in Codespaces, and running locally is that you will need to install Docker so that you can run the EventStoreDB docker containt. And you will also need to install either a JDK, a .NET sdk, python, or node.JS depending on which of the "From Scratch" projects you are running. Please see the document for details.
40+
41+
42+
### 3. Setting up a local environment
43+
44+
This document describes the steps we took to build these examples including
45+
* installing the programming language
46+
* creating a directory
47+
* setting up whatever additional tools are needed
48+
49+
Also included are the steps you would want to take to prepare your code for sharing on github, either publically, or privately within your organization.
50+
51+
These steps include:
52+
* initializing a directory for git
53+
* adding a .gitignore file
54+
* pushing your first commit
55+
56+
Those steps are in this document [Setting up a local environment From Scratch](./SettingUpALocalEnvironment.pdf)
57+
58+
59+
# Next Steps and Other Resources
60+
61+
Upon successful completion of your "From Scratch" project, you can continue practicing with the examples located at https://github.com/EventStore/samples.
62+
63+
In particular, the [Quickstart examples](https://GitHub.com/EventStore/samples/tree/main/Quickstart) contain more thorough examples, and include content referencing Go, Spring Boot, and Rust.
64+
65+
66+
67+
68+
# Supporting Documents
69+
Included in the top level directory are the required resources:
70+
1. A PDF [Instructions For Running in CodeSpaces](InstructionsForRunningInCodeSpaces.pdf) outlining the steps needed to launch codespaces.
71+
2. A PDF [Instructions For Running Locally](InstructionsForRunningLocally.pdf) describing how to run EventStoreDB locally, including step by step details on how we built the project.
72+
3. A PDF [Setting Up A Local Environment](SettingUpALocalEnvironment.pdf) describes the steps taken to build this project, that can be used as a template to get started on similar projects.
73+
74+
75+
# Most of all have fun! Once you know how to write and read events "From Scratch," you will be ready to cook up all sorts of tasty and more advanced recipes.
76+
77+

SettingUpALocalEnvironment.pdf

141 KB
Binary file not shown.

requirements.txt

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
esdbclient==1.0.19
2+
grpcio==1.62.1
3+
protobuf==5.26.1
4+
typing_extensions==4.10.0

sample_append.py

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
from esdbclient import EventStoreDBClient, NewEvent, StreamState
2+
3+
client = EventStoreDBClient(uri="esdb://localhost:2113?tls=false")
4+
5+
new_event = NewEvent(
6+
type="some-event",
7+
data=b'{"Id":"1", "value":"some data"}'
8+
)
9+
10+
client.append_to_stream(
11+
"SampleContent",
12+
events = [new_event],
13+
current_version = StreamState.ANY
14+
)
15+
client.close()
16+

sample_read.py

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
from esdbclient import EventStoreDBClient, NewEvent, StreamState
2+
3+
client = EventStoreDBClient(uri="esdb://localhost:2113?tls=false")
4+
5+
6+
7+
events = client.get_stream("SampleContent")
8+
9+
for event in events:
10+
print(event.data)
11+
12+
print("success")
13+
client.close()
14+
15+

start_cluster.sh

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#!/bin/bash
2+
####
3+
# Docker management script for Eventstore Training Classes
4+
#####
5+
6+
####
7+
# Check to see if instance is currently running
8+
# If instance is running kill it and start fresh instance
9+
########
10+
11+
#############
12+
# Some bash notes for the curious
13+
# ps --format returns just the names rather than the verbose table format
14+
# grep -q is search in silent mode to prevent output to the terminal
15+
# echo -e the -e allows echo of newline characters
16+
#######
17+
18+
19+
# Check to see if docker container is already running
20+
# If yes, kill it and restart
21+
# If no, download and start
22+
23+
24+
if docker ps --format '{{.Names}}'| grep -q esdb;
25+
then echo -e '\nesdb docker container appears to be running\n';
26+
27+
#docker ps --format '{{.Names}}'
28+
29+
# The following steps work
30+
31+
# 1 kill the container
32+
33+
docker stop esdb-node
34+
35+
## Remove the instance
36+
docker rm esdb-node
37+
38+
docker run -d --name esdb-node -it -p 2113:2113 -p 1113:1113 \
39+
eventstore/eventstore:lts --insecure --run-projections=All \
40+
--enable-external-tcp --enable-atom-pub-over-http
41+
42+
else
43+
docker run -d --name esdb-node -it -p 2113:2113 -p 1113:1113 \
44+
eventstore/eventstore:lts --insecure --run-projections=All \
45+
--enable-external-tcp --enable-atom-pub-over-http
46+
fi
47+
48+

0 commit comments

Comments
 (0)