EventSourced 开源项目教程

EventSourced 开源项目教程

eventsourcedA library for building reliable, scalable and distributed event-sourced applications in Scala项目地址:https://gitcode.com/gh_mirrors/ev/eventsourced

1. 项目的目录结构及介绍

EventSourced 项目的目录结构如下:

eventsourced/
├── eventsourced-nats/
├── eventsourced-postgres/
├── eventsourced-projection/
├── examples/
├── gitignore
├── Cargo.lock
├── Cargo.toml
├── LICENSE
├── README.md
├── justfile
├── rust-toolchain.toml
└── rustfmt.toml

目录介绍

  • eventsourced-nats/: NATS 实现的事件日志和快照存储。
  • eventsourced-postgres/: Postgres 实现的事件日志和快照存储。
  • eventsourced-projection/: 事件投影相关功能。
  • examples/: 项目示例代码。
  • gitignore: Git 忽略文件配置。
  • Cargo.lock: Cargo 依赖锁定文件。
  • Cargo.toml: Cargo 项目配置文件。
  • LICENSE: 项目许可证文件。
  • README.md: 项目说明文档。
  • justfile: 构建脚本文件。
  • rust-toolchain.toml: Rust 工具链配置文件。
  • rustfmt.toml: Rust 格式化配置文件。

2. 项目的启动文件介绍

项目的启动文件通常位于 examples/ 目录下,例如 NodeApp.scalaNodeApp.java。以下是一个示例启动文件的介绍:

// NodeApp.scala
package org.eligosource.eventsourced.example

import akka.actor._
import org.eligosource.eventsourced.core._

object NodeApp extends App {
  val system: ActorSystem = ActorSystem("node")
  val journal: ActorRef = ...
  val extension = EventsourcingExtension(system, journal)

  // 创建并注册事件源处理器
  extension.processorOf(...)

  // 创建并注册通道
  extension.channelOf(...)

  // 恢复注册处理器的状态并激活通道
  extension.recover()

  // 处理器和通道现在可以使用了
  // ...
}

启动文件介绍

  • NodeApp.scala: 启动应用程序的主文件,包含 ActorSystem 的初始化、事件日志的创建、事件源处理器和通道的注册以及状态恢复。

3. 项目的配置文件介绍

项目的配置文件主要包括 Cargo.tomlrust-toolchain.toml

Cargo.toml

Cargo.toml 是 Rust 项目的配置文件,包含项目的依赖、构建配置等信息。

[package]
name = "eventsourced"
version = "0.1.0"
edition = "2018"

[dependencies]
akka = "2.6.10"
eventsourced = { path = "eventsourced" }
eventsourced-nats = { path = "eventsourced-nats" }
eventsourced-postgres = { path = "eventsourced-postgres" }

rust-toolchain.toml

rust-toolchain.toml 是 Rust 工具链的配置文件,指定项目使用的 Rust 版本。

[toolchain]
channel = "stable"

配置文件介绍

  • Cargo.toml: 项目依赖和构建配置。
  • rust-toolchain.toml: 指定项目使用的 Rust 版本。

以上是 EventSourced 开源项目的教程,包含了项目的目录结构、启动文件和配置文件的介绍。希望对您有所帮助!

eventsourcedA library for building reliable, scalable and distributed event-sourced applications in Scala项目地址:https://gitcode.com/gh_mirrors/ev/eventsourced

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

杭律沛Meris

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值