Skip to content

Commit b20ac7b

Browse files
vlazarmichaelhixson
authored andcommitted
Update Crystal and frameworks (#4020)
* Update Crystal and frameworks * Generate Date header using HTTP.format_time Not only it is more idiomatic, but faster as well: Time.utc_now.to_s("%a, %d %b %Y %H:%M:%S GMT") 689.84k ( 1.45µs) (± 1.35%) 242 B/op 1.37× slower HTTP.format_time(Time.now) 941.75k ( 1.06µs) (± 1.83%) 242 B/op fastest * Remove unnecessary X-Powered-By: Kemal
1 parent 87c778d commit b20ac7b

23 files changed

+95
-72
lines changed

frameworks/Crystal/amber/amber.dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM crystallang/crystal:0.24.1
1+
FROM crystallang/crystal:0.26.1
22

33
WORKDIR /amber
44
COPY config config
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1-
require "granite_orm/adapter/pg"
1+
require "granite/adapter/pg"
22

3-
Granite::ORM.settings.logger = Logger.new(nil)
3+
Granite.settings.logger = Logger.new(nil)
4+
Granite::Adapters << Granite::Adapter::Pg.new({name: "pg", url: ENV["DATABASE_URL"]})

frameworks/Crystal/amber/shard.lock

+34-22
Original file line numberDiff line numberDiff line change
@@ -2,73 +2,85 @@ version: 1.0
22
shards:
33
amber:
44
github: amberframework/amber
5-
version: 0.6.7
5+
version: 0.9.0
6+
7+
amber_router:
8+
github: amberframework/amber-router
9+
version: 0.2.0
610

711
callback:
812
github: mosop/callback
913
version: 0.6.3
1014

1115
cli:
12-
github: amberframework/cli
16+
github: mosop/cli
1317
version: 0.7.0
1418

19+
compiled_license:
20+
github: elorest/compiled_license
21+
version: 0.1.3
22+
1523
db:
1624
github: crystal-lang/crystal-db
1725
version: 0.5.0
1826

19-
granite_orm:
20-
github: amberframework/granite-orm
21-
version: 0.8.4
27+
granite:
28+
github: amberframework/granite
29+
version: 0.13.1
30+
31+
inflector:
32+
github: phoffer/inflector.cr
33+
version: 0.1.8
2234

2335
kilt:
2436
github: jeromegn/kilt
2537
version: 0.4.0
2638

27-
micrate:
28-
github: juanedi/micrate
39+
liquid:
40+
github: TechMagister/liquid.cr
2941
version: 0.3.0
3042

43+
micrate:
44+
github: amberframework/micrate
45+
version: 0.3.3
46+
3147
mysql:
3248
github: crystal-lang/crystal-mysql
33-
version: 0.4.0
49+
version: 0.5.0
3450

3551
optarg:
3652
github: mosop/optarg
3753
version: 0.5.8
3854

3955
pg:
4056
github: will/crystal-pg
41-
version: 0.14.1
57+
version: 0.15.0
4258

43-
radix:
44-
github: luislavena/radix
45-
version: 0.3.8
59+
pool:
60+
github: ysbaddaden/pool
61+
version: 0.2.3
4662

4763
redis:
4864
github: stefanwille/crystal-redis
49-
version: 1.9.0
65+
version: 2.0.0
5066

5167
shell-table:
52-
github: jwaldrip/shell-table.cr
53-
version: 0.9.2
68+
github: luckyframework/shell-table.cr
69+
commit: 078a04ea58ead5203bb435a3b5fff448ddabaeea
5470

5571
slang:
5672
github: jeromegn/slang
5773
version: 1.7.1
5874

59-
spinner:
60-
github: askn/spinner
61-
version: 0.1.1
62-
6375
sqlite3:
6476
github: crystal-lang/crystal-sqlite3
65-
version: 0.9.0
77+
version: 0.10.0
6678

6779
string_inflection:
6880
github: mosop/string_inflection
6981
version: 0.2.1
7082

7183
teeplate:
72-
github: amberframework/teeplate
73-
version: 0.5.0
84+
github: mosop/teeplate
85+
version: 0.6.1
7486

frameworks/Crystal/amber/shard.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ targets:
1313
dependencies:
1414
amber:
1515
github: amberframework/amber
16-
version: 0.6.7
16+
version: 0.9.0
1717

18-
granite_orm:
19-
github: amberframework/granite-orm
20-
version: 0.8.4
18+
granite:
19+
github: amberframework/granite
20+
version: 0.13.1

frameworks/Crystal/amber/src/controllers/benchmark_controller.cr

+5-5
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ class BenchmarkController < Amber::Controller::Base
88
before_action do
99
all do
1010
response.headers["Server"] = "Amber"
11-
response.headers["Date"] = Time.utc_now.to_s("%a, %d %b %Y %H:%M:%S GMT")
11+
response.headers["Date"] = HTTP.format_time(Time.now)
1212
end
1313
end
1414

@@ -26,7 +26,7 @@ class BenchmarkController < Amber::Controller::Base
2626
response.content_type = JSON
2727
results = {} of Symbol => Int32
2828
if world = World.find rand(1..ID_MAXIMUM)
29-
results = {id: world.id, randomNumber: world.randomNumber}
29+
results = {id: world.id, randomNumber: world.randomnumber}
3030
end
3131
results.to_json
3232
end
@@ -39,7 +39,7 @@ class BenchmarkController < Amber::Controller::Base
3939

4040
results = (1..queries).map do
4141
if world = World.find rand(1..ID_MAXIMUM)
42-
{id: world.id, randomNumber: world.randomNumber}
42+
{id: world.id, randomNumber: world.randomnumber}
4343
end
4444
end
4545

@@ -54,9 +54,9 @@ class BenchmarkController < Amber::Controller::Base
5454

5555
results = (1..queries).map do
5656
if world = World.find rand(1..ID_MAXIMUM)
57-
world.randomNumber = rand(1..ID_MAXIMUM)
57+
world.randomnumber = rand(1..ID_MAXIMUM)
5858
world.save
59-
{id: world.id, randomNumber: world.randomNumber}
59+
{id: world.id, randomNumber: world.randomnumber}
6060
end
6161
end
6262

frameworks/Crystal/amber/src/models/fortune.cr

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
require "granite_orm/adapter/pg"
1+
require "granite/adapter/pg"
22

3-
class Fortune < Granite::ORM::Base
3+
class Fortune < Granite::Base
44
adapter pg
55

66
table_name fortune
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
require "granite_orm/adapter/pg"
1+
require "granite/adapter/pg"
22

3-
class World < Granite::ORM::Base
3+
class World < Granite::Base
44
adapter pg
55

66
table_name world
77
primary id : Int32
8-
field randomNumber : Int32
8+
field randomnumber : Int32
99
end

frameworks/Crystal/crystal/crystal-radix.dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM crystallang/crystal:0.24.1
1+
FROM crystallang/crystal:0.26.1
22

33
WORKDIR /crystal
44
COPY views views

frameworks/Crystal/crystal/crystal.dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM crystallang/crystal:0.24.1
1+
FROM crystallang/crystal:0.26.1
22

33
WORKDIR /crystal
44
COPY views views

frameworks/Crystal/crystal/server.cr

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ require "ecr"
66
APPDB = DB.open("postgres://benchmarkdbuser:benchmarkdbpass@tfb-database:5432/hello_world?initial_pool_size=256&max_pool_size=256&max_idle_pool_size=256")
77
ID_MAXIMUM = 10_000
88

9-
server = HTTP::Server.new("0.0.0.0", 8080) do |context|
9+
server = HTTP::Server.new do |context|
1010
response = context.response
1111
request = context.request
1212

1313
response.headers["Server"] = "Crystal"
14-
response.headers["Date"] = Time.utc_now.to_s("%a, %d %b %Y %H:%M:%S GMT")
14+
response.headers["Date"] = HTTP.format_time(Time.now)
1515

1616
case request.path
1717
when "/json"
@@ -95,4 +95,4 @@ private def sanitized_query_count(request)
9595
queries.clamp(1..500)
9696
end
9797

98-
server.listen(reuse_port: true)
98+
server.listen("0.0.0.0", 8080, reuse_port: true)

frameworks/Crystal/crystal/server_radix.cr

+3-3
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,11 @@ tree.add "/updates", updates_handler
9292
APPDB = DB.open("postgres://benchmarkdbuser:benchmarkdbpass@tfb-database:5432/hello_world")
9393
ID_MAXIMUM = 10_000
9494

95-
server = HTTP::Server.new("0.0.0.0", 8080) do |context|
95+
server = HTTP::Server.new do |context|
9696
request = context.request
9797
response = context.response
9898
response.headers["Server"] = "Crystal"
99-
response.headers["Date"] = Time.utc_now.to_s("%a, %d %b %Y %H:%M:%S GMT")
99+
response.headers["Date"] = HTTP.format_time(Time.now)
100100

101101
result = tree.find(request.path)
102102

@@ -134,4 +134,4 @@ private def sanitized_query_count(request)
134134
queries.clamp(1..500)
135135
end
136136

137-
server.listen(reuse_port: true)
137+
server.listen("0.0.0.0", 8080, reuse_port: true)

frameworks/Crystal/crystal/shard.lock

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ shards:
66

77
pg:
88
github: will/crystal-pg
9-
version: 0.14.1
9+
version: 0.15.0
1010

1111
radix:
1212
github: luislavena/radix

frameworks/Crystal/crystal/shard.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ license: MIT
66
dependencies:
77
pg:
88
github: will/crystal-pg
9-
version: 0.14.1
9+
version: 0.15.0
1010

1111
radix:
1212
github: luislavena/radix

frameworks/Crystal/h2o.cr/h2o.cr.dockerfile

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ RUN apt update \
44
&& apt install -yqq libh2o-evloop-dev libwslay-dev libyaml-0-2 libevent-dev libpcre3-dev \
55
gcc wget git libssl-dev libuv1-dev ca-certificates --no-install-recommends
66

7-
RUN wget -q https://github.com/crystal-lang/crystal/releases/download/0.24.2/crystal-0.24.2-1-linux-x86_64.tar.gz \
8-
&& tar --strip-components=1 -xzf crystal-0.24.2-1-linux-x86_64.tar.gz -C /usr/ \
7+
RUN wget -q https://github.com/crystal-lang/crystal/releases/download/0.26.1/crystal-0.26.1-1-linux-x86_64.tar.gz \
8+
&& tar --strip-components=1 -xzf crystal-0.26.1-1-linux-x86_64.tar.gz -C /usr/ \
99
&& rm -f *.tar.gz
1010

1111
WORKDIR /crystal

frameworks/Crystal/h2o.cr/shard.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ version: 0.0.1
33

44
license: MIT
55

6-
crystal: 0.24.2
6+
crystal: 0.26.1
77

88
dependencies:
99
h2o:

frameworks/Crystal/kemal/kemal.dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM crystallang/crystal:0.24.1
1+
FROM crystallang/crystal:0.26.1
22

33
WORKDIR /kemal
44
COPY views views

frameworks/Crystal/kemal/server-postgres.cr

+3-2
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ end
4444

4545
before_all do |env|
4646
env.response.headers["Server"] = "Kemal"
47-
env.response.headers["Date"] = Time.utc_now.to_s("%a, %d %b %Y %H:%M:%S GMT")
47+
env.response.headers["Date"] = HTTP.format_time(Time.now)
4848
end
4949

5050
#
@@ -111,6 +111,7 @@ end
111111
Kemal.config do |cfg|
112112
cfg.serve_static = false
113113
cfg.logging = false
114+
cfg.powered_by_header = false
114115
end
115116

116-
Kemal.run { |cfg| cfg.server.not_nil!.bind(reuse_port: true) }
117+
Kemal.run { |cfg| cfg.server.not_nil!.bind_tcp(cfg.host_binding, cfg.port, reuse_port: true) }

frameworks/Crystal/kemal/shard.lock

+11-3
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,31 @@ shards:
44
github: crystal-lang/crystal-db
55
version: 0.5.0
66

7+
exception_page:
8+
github: crystal-loot/exception_page
9+
version: 0.1.1
10+
711
kemal:
812
github: kemalcr/kemal
9-
version: 0.22.0
13+
version: 0.24.0
1014

1115
kilt:
1216
github: jeromegn/kilt
1317
version: 0.4.0
1418

1519
pg:
1620
github: will/crystal-pg
17-
version: 0.14.1
21+
version: 0.15.0
22+
23+
pool:
24+
github: ysbaddaden/pool
25+
version: 0.2.3
1826

1927
radix:
2028
github: luislavena/radix
2129
version: 0.3.8
2230

2331
redis:
2432
github: stefanwille/crystal-redis
25-
version: 1.9.0
33+
version: 2.0.0
2634

frameworks/Crystal/kemal/shard.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ license: MIT
66
dependencies:
77
pg:
88
github: will/crystal-pg
9-
version: 0.14.1
9+
version: 0.15.0
1010
kemal:
1111
github: kemalcr/kemal
12-
version: 0.22.0
12+
version: 0.24.0
1313
redis:
1414
github: stefanwille/crystal-redis
15-
version: 1.9.0
15+
version: 2.0.0

0 commit comments

Comments
 (0)