Marten

.NET 事务性文档数据库和 PostgreSQL 上的事件存储。「.NET Transactional Document DB and Event Store on PostgreSQL」

Github stars Tracking Chart

Marten

.NET 事务性文档数据库和 PostgreSQL 上的事件存储。

Marten 库为 .NET 开发人员提供了使用成熟的 PostgreSQL 数据库引擎 及其 梦幻般的 JSON 支持 作为一个完全成熟的 文档数据库 的能力。Marten 团队认为文档数据库比起有或没有 ORM 工具的关系型数据库,对开发者的生产力有着深远的好处。

Marten 还为 .NET 开发人员提供了一个符合 ACID 标准的事件存储,并可针对事件流进行用户定义的预测。

使用代码

在开始之前,您的环境中需要以下内容:

1. .NET Core SDK 5.0+ 和 .NET Core 3.1 Runtime

此处

2. 启用了 PLV8 的 PostgreSQL 9.6 或以上数据库

使用 Marten 进行开发的最快方式是在 Docker 容器中运行 PostgreSQL。假设你的本地机器上运行着 Docker,在命令行键入 dotnet run -- init-db 来启动一个启用了 PLV8 的 PostgreSQL 数据库,并进行配置。如果没有按照下面的步骤明确配置 PostgreSQL 数据库连接字符串,默认的 Marten 测试配置会尝试找到这个数据库。

你需要在 PostgreSQL 内部启用 PLV8 扩展,以便运行 JavaScript 存储过程,以支持新生项目。

确保以下几点:

  • 你用来连接数据库的登录名是 postgres 角色的成员。
  • marten_testing_database 的环境变量被设置为你想用作测试平台的数据库的连接字符串。(更多关于 PostgreSQL 连接字符串的信息请参见 Npgsql 文档)。

PSQL/PLV8 的帮助

  • 在 Windows 上,请参见 这个链接 以获取 PLV8 的预建二进制文件。
  • 在 *nix 上,检查 marten-local-db,寻找基于 Docker 的 PostgreSQL 实例,包括 PLV8。

一旦你有了代码库和连接字符串文件,运行构建命令或使用 dotnet CLI 来恢复和构建解决方案。

现在您已经准备好向 Marten 做出贡献了。

更多内容请参见 贡献指南

工具

构建命令

Description Windows Commandline PowerShell Linux Shell DotNet CLI
Run restore, build and test build.cmd build.ps1 build.sh dotnet build src\Marten.sln
Run all tests including mocha tests build.cmd test build.ps1 test build.sh test dotnet run -p martenbuild.csproj -- test
Run just mocha tests build.cmd mocha build.ps1 mocha build.sh mocha dotnet run -p martenbuild.csproj -- mocha
Run StoryTeller tests build.cmd storyteller build.ps1 storyteller build.sh storyteller dotnet run -p martenbuild.csproj -- storyteller
Open StoryTeller editor build.cmd open_st build.ps1 open_st build.sh open_st dotnet run -p martenbuild.csproj -- open_st
Run documentation website locally build.cmd docs build.ps1 docs build.sh docs dotnet run -p martenbuild.csproj -- docs
Publish docs build.cmd publish-docs build.ps1 publish-docs build.sh publish-docs dotnet run -p martenbuild.csproj -- publish-docs
Run benchmarks build.cmd benchmarks build.ps1 benchmarks build.sh benchmarks dotnet run -p martenbuild.csproj -- benchmarks

注意:在运行单元测试或 StoryTeller 测试时,您应该有一个正在运行的 Postgres 实例。

xUnit.Net 规格

为了帮助集成测试,Marten.Testing 有几个可重用的基类,可以用来使通过 Postgresql 进行的集成测试更加高效,并使 xUnit.Net 测试能够并行运行以获得更好的吞吐量。

  • IntegrationContext -- 如果大多数测试将使用开箱即用的配置(即没有任何文档类型的流畅接口配置),使用这个基类。但警告,这个上下文类型不会在运行之间清理主公共数据库模式,但会删除任何现有数据。
  • DestructiveIntegrationContext -- 类似于 IntegrationContext,但会在测试之间抹去公共模式中的任何和所有 Postgresql 模式对象。请少用这个。
  • OneOffConfigurationsContext -- 如果测试套件需要频繁地重新配置DocumentStore,那么这个上下文是合适的。你将需要用 [Collection] 属性来修饰这些测试类中的任何一个,通常使用集合名的模式名作为约定。
  • BugIntegrationContext -- 针对 bug 的测试往往需要定制的 DocumentStore 配置,而这个上下文是针对 bug 方案的 OneOffConfigurationsContext 的特殊化。

如果一系列测试使用相同的自定义 DocumentStore 配置,StoreFixture 和 StoreContext 是很有帮助的。你需要写一个 StoreFixture 的子类,然后使用StoreContext<yournewstorefixture> 作为基类,在测试运行之间用 xUnit.Net 的共享上下文(IClassFixture<t>)共享 DocumentStore。

Mocha 规格

参考构建命令部分,查找运行 Mocha 测试的命令。还有 npm run tdd 可以在开启 growl 的情况下,以监视模式运行 mocha 规范。

注意:记得运行 npm install

Storyteller 规格

请参阅构建命令部分,查找打开 StoryTeller 编辑器或运行 StoryTeller 规范的命令。

文档介绍

文档内容是指项目根目录下直接的 /documentation 目录下的 markdown 文件。要在本地运行自动刷新的文档网站,请参考上面的构建命令部分。

如果你想从测试中向文档页面插入代码样本,请用 // SAMPLE:name-of-sample和 // ENDSAMPLE 来包装你想插入的代码。然后要将该代码插入到文档中,请添加 <[sample:name-of-sample]>。

注意:内容发布到本仓库的 gh-pages 分支。請參考建構指令一節來尋找發佈文件的指令。

许可证

Copyright © .NET Foundation, Jeremy D. Miller, Babu Annamalai, Oskar Dudycz, Joona-Pekka Kokko and contributors.

Marten 是在 MIT 许可下按原样提供的。更多信息请参见 LICENSE。

行为准则

本项目采用了贡献者公约所定义的行为准则,以明确我们社区中的预期行为。更多信息请参见 .NET 基金会行为准则。

.NET基金会

这个项目得到了 .NET 基金会 的支持。


(The first version translated by vz on 2020.12.12)

Overview

Name With Ownershlinkio/shlink
Primary LanguagePHP
Program languageC# (Language Count: 4)
PlatformLinux, Windows, Docker, Mac
License:MIT License
Release Count127
Last Release Namev4.0.3 (Posted on 2024-03-15 23:07:52)
First Release Namev0.1.0 (Posted on 2016-05-02 17:29:47)
Created At2016-04-08 18:44:25
Pushed At2024-03-20 08:15:52
Last Commit At
Stargazers Count2.7k
Watchers Count22
Fork Count220
Commits Count4.1k
Has Issues Enabled
Issues Count1109
Issue Open Count29
Pull Requests Count722
Pull Requests Open Count1
Pull Requests Close Count30
Has Wiki Enabled
Is Archived
Is Fork
Is Locked
Is Mirror
Is Private

Marten

Polyglot Persistence Powered by .NET and PostgreSQL

Join the chat at https://gitter.im/JasperFx/Marten
Windows Build Status
Linux Build status
Nuget Package

marten logo

The Marten library provides .NET developers with the ability to use the proven PostgreSQL database engine and its fantastic JSON support as a fully fledged document database. The Marten team believes that a document database has far reaching benefits for developer productivity over relational databases with or without an ORM tool.

Marten also provides .NET developers with an ACID-compliant event store with user-defined projections against event streams.

Working with the Code

Before getting started you will need the following in your environment:

1. .NET Core SDK 2.1 (or higher)

Available here

2. .NET Framework 4.6.1 Developer Pack

Available here

3. PostgreSQL 9.5+ database with PLV8

You need to enable the PLV8 extension inside of PostgreSQL for running JavaScript stored procedures for the nascent projection support.

Ensure the following:

  • The login you are using to connect to your database is a member of the postgres role
  • An environment variable of marten_testing_database is set to the connection string for the database you want to use as a testbed. (See the Npgsql documentation for more information about PostgreSQL connection strings ).

Help with PSQL/PLV8

  • On Windows, see this link for pre-built binaries of PLV8
  • On *nix, check marten-local-db for a Docker based PostgreSQL instance including PLV8.

Once you have the codebase and the connection string file, run the rake script or use the dotnet CLI to restore and build the solution.

You are now ready to contribute to Marten.

Tooling

Build Commands

Description

To the top