Skip to content
This repository has been archived by the owner on Apr 13, 2020. It is now read-only.

CrystalとWeb 2 #5

Merged
merged 6 commits into from
Oct 23, 2017
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
sidekiqは今回扱わない
  • Loading branch information
msky026 committed Sep 30, 2017
commit 336481b31bc22a2e5086044acabacbc48cb5625e
21 changes: 4 additions & 17 deletions msky026/README.md
Original file line number Diff line number Diff line change
@@ -4,17 +4,14 @@ Twitter: @msky026

# はじめに

1年前の技術書典1で記述しました、「CrystalとWeb」からの変更点を主に纏めます。
内容は以下のとおりです。

- Kemalの変更点
- Sidekiq.crと組み合わせて非同期処理を実現する
1年前の技術書典1で「CrystalとWeb」について記述しました。
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

内容が前に作ったものを修正していくようになっているので、どこかで前回何を作ったのか説明があるといいかもしれません。

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

前回作ったものの情報はリポジトリにあるのでそのurlを追記しました。

CrystalやKemalもそれから多くの点で変更になりましたが、本稿では主にDBの扱い方について解説します。

# Kemalの変更点

## DB接続設定の変更

まず主だった変更点として、DB接続を行うモジュールが変更になっています
まず主だった変更点として、DB接続を行うモジュールが変更されましt
以前はPostgreSQLを使用する際はkemal-pgを使ってDBに接続していましたが、DB接続関連は[crystal-db](https://github.com/crystal-lang/crystal-db)のライブラリがデファクトスタンダードになっています。こちらのライブラリは現時点でコネクションプールも備えております。
以前はコネクションプール使用時には専用のライブラリを使用していましたがそれも不要になりました。

@@ -33,7 +30,7 @@ dependencies:
branch: master

dependencies:
crystal-db:
db:
github: crystal-lang/crystal-db
branch: master
```
@@ -196,13 +193,3 @@ db.exec("update articles set title = $1::text, body = $2::text where id = $3::in
</table>
```

## Sidekiq.crと組み合わせて非同期処理を実現する

Crystalで非同期処理を行いたい場合は、Sidekiqを使用することである程度可能になります。
Rubyでよく使用されるSidekiqのCrystal版があります。

[Sidekiq.cr](https://github.com/mperham/sidekiq.cr)