Skip to content

Commit 7bd8f61

Browse files
authored
Amber framework updated to 1.4 (#8575)
* Amber framework update * Amber pool size config * Max pool size 28 * Amber fix * Amber gitignore * Amber process count * Amber docker static compilation
1 parent ee15f90 commit 7bd8f61

File tree

10 files changed

+148
-75
lines changed

10 files changed

+148
-75
lines changed

frameworks/Crystal/amber/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
lib/*
Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,37 @@
1-
FROM crystallang/crystal:0.26.1
1+
FROM crystallang/crystal:1.10.1-alpine as build
22

33
WORKDIR /amber
44
COPY config config
55
COPY src src
6-
COPY run.sh run.sh
6+
77
COPY shard.lock shard.lock
88
COPY shard.yml shard.yml
99

10-
ENV GC_MARKERS 1
10+
RUN apk update
11+
RUN apk add yaml-dev sqlite-dev
12+
13+
# RUN shards build amber --release
14+
RUN shards install
15+
RUN crystal build --release --no-debug --static src/amber.cr
16+
RUN cp amber bin/amber
17+
18+
# Main Image
19+
FROM ubuntu:22.04
20+
21+
WORKDIR /amber
22+
1123
ENV AMBER_ENV production
12-
ENV DATABASE_URL postgres://benchmarkdbuser:benchmarkdbpass@tfb-database:5432/hello_world?initial_pool_size=56&max_pool_size=56&max_idle_pool_size=56
24+
ENV DATABASE_URL postgres://benchmarkdbuser:benchmarkdbpass@tfb-database:5432/hello_world?initial_pool_size=10&max_idle_pool_size=10&retry_attempts=3&retry_delay=1
1325

26+
RUN apt-get update
1427
RUN apt-get install -yqq libyaml-dev
15-
RUN shards build amber --release --no-debug
28+
29+
COPY run.sh run.sh
30+
RUN mkdir bin
31+
COPY --from=build /amber/amber /amber/bin/amber
1632

1733
EXPOSE 8080
1834

1935
CMD bash run.sh
36+
37+

frameworks/Crystal/amber/config/application.cr

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,14 @@ Amber::Server.configure do |settings|
2727
#
2828
# > Read more about Linux PORT REUSE https://lwn.net/Articles/542629/
2929
#
30-
settings.port_reuse = false
30+
settings.port_reuse = true
3131
#
3232
#
3333
# Process Count: This will enable Amber to be used in cluster mode,
3434
# spinning an instance for each number of process specified here.
3535
# Rule of thumb, always leave at least 1 core available for system processes/resources.
3636
#
37-
settings.process_count = 1
37+
settings.process_count = (System.cpu_count).to_i32
3838
#
3939
#
4040
# PORT: This is the port that you're application will run on. Examples would be (80, 443, 3000, 8080)
@@ -45,7 +45,5 @@ Amber::Server.configure do |settings|
4545
# Log: Is the logger that will be used for Amber and it defaults to ::Logger.new(STDOUT).
4646
# You can supply a custom logger.
4747
#
48-
settings.logger = Amber::Environment::Logger.new(nil)
49-
#
50-
#
51-
end
48+
settings.logging.severity = "info"
49+
end
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
require "granite/adapter/pg"
22

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

frameworks/Crystal/amber/run.sh

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
#!/bin/bash
22

3-
for i in $(seq 1 $(nproc --all)); do
4-
./bin/amber &
5-
done
3+
./bin/amber
64

7-
wait

frameworks/Crystal/amber/shard.lock

Lines changed: 85 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,86 +1,126 @@
1-
version: 1.0
1+
version: 2.0
22
shards:
33
amber:
4-
github: amberframework/amber
5-
version: 0.9.0
4+
git: https://github.com/amberframework/amber.git
5+
version: 1.4.1
66

77
amber_router:
8-
github: amberframework/amber-router
9-
version: 0.2.0
8+
git: https://github.com/amberframework/amber-router.git
9+
version: 0.4.4
10+
11+
backtracer:
12+
git: https://github.com/sija/backtracer.cr.git
13+
version: 1.2.2
1014

1115
callback:
12-
github: mosop/callback
13-
version: 0.6.3
16+
git: https://github.com/amberframework/callback.git
17+
version: 0.9.2
1418

1519
cli:
16-
github: mosop/cli
17-
version: 0.7.0
20+
git: https://github.com/amberframework/cli.git
21+
version: 0.11.4
1822

1923
compiled_license:
20-
github: elorest/compiled_license
21-
version: 0.1.3
24+
git: https://github.com/elorest/compiled_license.git
25+
version: 1.2.2
2226

2327
db:
24-
github: crystal-lang/crystal-db
25-
version: 0.5.0
28+
git: https://github.com/crystal-lang/crystal-db.git
29+
version: 0.11.0
30+
31+
dotenv:
32+
git: https://github.com/gdotdesign/cr-dotenv.git
33+
version: 1.0.0
34+
35+
exception_page:
36+
git: https://github.com/crystal-loot/exception_page.git
37+
version: 0.3.1
38+
39+
future:
40+
git: https://github.com/crystal-community/future.cr.git
41+
version: 1.0.0
2642

2743
granite:
28-
github: amberframework/granite
29-
version: 0.13.1
44+
git: https://github.com/amberframework/granite.git
45+
version: 0.23.3
46+
47+
i18n:
48+
git: https://github.com/crimson-knight/i18n.cr.git
49+
version: 0.4.1
50+
51+
ifrit:
52+
git: https://github.com/imdrasil/ifrit.git
53+
version: 0.1.3
3054

3155
inflector:
32-
github: phoffer/inflector.cr
33-
version: 0.1.8
56+
git: https://github.com/phoffer/inflector.cr.git
57+
version: 1.0.0
58+
59+
jennifer:
60+
git: https://github.com/imdrasil/jennifer.cr.git
61+
version: 0.13.0
62+
63+
json_mapping:
64+
git: https://github.com/crystal-lang/json_mapping.cr.git
65+
version: 0.1.1
3466

3567
kilt:
36-
github: jeromegn/kilt
37-
version: 0.4.0
68+
git: https://github.com/jeromegn/kilt.git
69+
version: 0.6.1
3870

3971
liquid:
40-
github: TechMagister/liquid.cr
41-
version: 0.3.0
72+
git: https://github.com/dare892/liquid.cr.git
73+
version: 0.4.1+git.commit.e4ef5ca06bf5bafe74e0b270c7aae2941a91ddd3
4274

4375
micrate:
44-
github: amberframework/micrate
45-
version: 0.3.3
76+
git: https://github.com/amberframework/micrate.git
77+
version: 0.15.0
4678

4779
mysql:
48-
github: crystal-lang/crystal-mysql
49-
version: 0.5.0
80+
git: https://github.com/crystal-lang/crystal-mysql.git
81+
version: 0.14.0
5082

5183
optarg:
52-
github: mosop/optarg
53-
version: 0.5.8
84+
git: https://github.com/amberframework/optarg.git
85+
version: 0.9.3
5486

5587
pg:
56-
github: will/crystal-pg
57-
version: 0.15.0
88+
git: https://github.com/will/crystal-pg.git
89+
version: 0.26.0
5890

5991
pool:
60-
github: ysbaddaden/pool
61-
version: 0.2.3
92+
git: https://github.com/ysbaddaden/pool.git
93+
version: 0.3.0
6294

6395
redis:
64-
github: stefanwille/crystal-redis
65-
version: 2.0.0
96+
git: https://github.com/stefanwille/crystal-redis.git
97+
version: 2.8.3
98+
99+
sam:
100+
git: https://github.com/imdrasil/sam.cr.git
101+
version: 0.5.0
66102

67103
shell-table:
68-
github: luckyframework/shell-table.cr
69-
commit: 078a04ea58ead5203bb435a3b5fff448ddabaeea
104+
git: https://github.com/luckyframework/shell-table.cr.git
105+
version: 0.9.3
70106

71107
slang:
72-
github: jeromegn/slang
73-
version: 1.7.1
108+
git: https://github.com/jeromegn/slang.git
109+
version: 1.7.3
74110

75111
sqlite3:
76-
github: crystal-lang/crystal-sqlite3
77-
version: 0.10.0
78-
79-
string_inflection:
80-
github: mosop/string_inflection
81-
version: 0.2.1
112+
git: https://github.com/crystal-lang/crystal-sqlite3.git
113+
version: 0.19.0
82114

83115
teeplate:
84-
github: mosop/teeplate
85-
version: 0.6.1
116+
git: https://github.com/amberframework/teeplate.git
117+
version: 0.11.2
118+
119+
wordsmith:
120+
git: https://github.com/luckyframework/wordsmith.git
121+
version: 0.4.0
122+
123+
yaml_mapping:
124+
git: https://github.com/crystal-lang/yaml_mapping.cr.git
125+
version: 0.1.1
86126

frameworks/Crystal/amber/shard.yml

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: amber
2-
version: 0.1.0
2+
version: 0.2.0
33

44
authors:
55
- Amber Team and Contributors <amberframework.org>
@@ -13,8 +13,28 @@ targets:
1313
dependencies:
1414
amber:
1515
github: amberframework/amber
16-
version: 0.9.0
16+
version: 1.4.1
17+
18+
jennifer:
19+
github: imdrasil/jennifer.cr
20+
version: "~> 0.13.0"
21+
22+
sam:
23+
github: imdrasil/sam.cr
24+
version: 0.5.0
25+
26+
pg:
27+
github: will/crystal-pg
28+
version: "= 0.26.0"
29+
30+
mysql:
31+
github: crystal-lang/crystal-mysql
32+
version: 0.14.0
33+
34+
dotenv:
35+
github: gdotdesign/cr-dotenv
36+
version: 1.0.0
1737

1838
granite:
1939
github: amberframework/granite
20-
version: 0.13.1
40+
version: 0.23.3

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

Lines changed: 1 addition & 1 deletion
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"] = HTTP.format_time(Time.now)
11+
response.headers["Date"] = HTTP.format_time(Time.local)
1212
end
1313
end
1414

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
require "granite/adapter/pg"
22

33
class Fortune < Granite::Base
4-
adapter pg
5-
6-
table_name fortune
7-
primary id : Int32
8-
field message : String
4+
connection pg
5+
table fortune
6+
7+
column id : Int32, primary: true
8+
column message : String
99
end
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
require "granite/adapter/pg"
22

33
class World < Granite::Base
4-
adapter pg
4+
connection pg
5+
table world
56

6-
table_name world
7-
primary id : Int32
8-
field randomnumber : Int32
7+
column id : Int32, primary: true
8+
column randomnumber : Int32
99
end

0 commit comments

Comments
 (0)