itsi 0.2.2 → 0.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +1 -1
  3. data/Cargo.lock +29 -30
  4. data/README.md +1 -0
  5. data/crates/itsi_scheduler/Cargo.toml +1 -1
  6. data/crates/itsi_server/Cargo.toml +1 -1
  7. data/crates/itsi_server/src/ruby_types/itsi_server/itsi_server_config.rs +26 -3
  8. data/docs/content/_index.md +1 -1
  9. data/docs/content/contact/_index.md +1 -1
  10. data/docs/content/directory_listing.jpg +0 -0
  11. data/docs/content/error_page.jpg +0 -0
  12. data/docs/content/getting_started/local_development.md +9 -2
  13. data/docs/content/getting_started/logging.md +1 -2
  14. data/docs/content/getting_started/signals.md +0 -1
  15. data/docs/hugo.yaml +3 -0
  16. data/gems/scheduler/Cargo.lock +74 -17
  17. data/gems/scheduler/itsi-scheduler.gemspec +2 -2
  18. data/gems/scheduler/lib/itsi/scheduler/version.rb +1 -1
  19. data/gems/server/Cargo.lock +28 -29
  20. data/gems/server/itsi-server.gemspec +2 -2
  21. data/gems/server/lib/itsi/http_request.rb +31 -34
  22. data/gems/server/lib/itsi/http_response.rb +10 -8
  23. data/gems/server/lib/itsi/passfile.rb +6 -6
  24. data/gems/server/lib/itsi/server/config/config_helpers.rb +33 -33
  25. data/gems/server/lib/itsi/server/config/dsl.rb +14 -19
  26. data/gems/server/lib/itsi/server/config/known_paths.rb +11 -7
  27. data/gems/server/lib/itsi/server/config/middleware/error_response.md +13 -0
  28. data/gems/server/lib/itsi/server/config/middleware/static_assets.md +40 -0
  29. data/gems/server/lib/itsi/server/config/option.rb +0 -1
  30. data/gems/server/lib/itsi/server/config/options/nodelay.md +2 -2
  31. data/gems/server/lib/itsi/server/config/options/reuse_address.md +1 -1
  32. data/gems/server/lib/itsi/server/config/typed_struct.rb +32 -35
  33. data/gems/server/lib/itsi/server/config.rb +107 -92
  34. data/gems/server/lib/itsi/server/default_app/default_app.rb +1 -1
  35. data/gems/server/lib/itsi/server/grpc/grpc_call.rb +4 -5
  36. data/gems/server/lib/itsi/server/grpc/grpc_interface.rb +6 -7
  37. data/gems/server/lib/itsi/server/rack/handler/itsi.rb +0 -1
  38. data/gems/server/lib/itsi/server/rack_interface.rb +0 -1
  39. data/gems/server/lib/itsi/server/route_tester.rb +25 -23
  40. data/gems/server/lib/itsi/server/typed_handlers/source_parser.rb +9 -7
  41. data/gems/server/lib/itsi/server/version.rb +1 -1
  42. data/gems/server/lib/itsi/server.rb +21 -21
  43. data/gems/server/lib/itsi/standard_headers.rb +80 -80
  44. data/gems/server/test/helpers/test_helper.rb +17 -16
  45. data/gems/server/test/middleware/test_log_requests.rb +54 -2
  46. data/gems/server/test/options/test_workers.rb +12 -5
  47. data/lib/itsi/version.rb +1 -1
  48. metadata +9 -13
  49. data/examples/static_assets_example.rb +0 -83
  50. data/grpc_test/Itsi.rb +0 -11
  51. data/grpc_test/echo.proto +0 -14
  52. data/grpc_test/echo_pb.rb +0 -16
  53. data/grpc_test/echo_service_impl.rb +0 -8
  54. data/grpc_test/echo_services_pb.rb +0 -22
@@ -1,16 +1,23 @@
1
1
  require_relative "../helpers/test_helper"
2
2
 
3
3
  class TestWorkers < Minitest::Test
4
-
5
4
  def test_it_can_run_multiple_workers
6
- worker_count = 3
5
+ worker_count = 4
7
6
 
8
7
  server(
9
8
  itsi_rb: lambda do
10
9
  workers worker_count
11
- get("/foo"){|r| r.ok Process.pid}
12
- end) do
13
- assert_equal worker_count, 50.times.map { |i| get("/foo") }.uniq.size
10
+ get("/foo") { |r| r.ok Process.pid }
11
+ end
12
+ ) do
13
+ seen = Set.new
14
+ Timeout.timeout(2) do
15
+ loop do
16
+ seen << get("foo")
17
+ break if seen.size == worker_count
18
+ end
19
+ end
20
+ assert_equal worker_count, seen.size
14
21
  end
15
22
  end
16
23
  end
data/lib/itsi/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Itsi
2
- VERSION = "0.2.2"
2
+ VERSION = '0.2.3'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: itsi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Wouter Coppieters
@@ -15,28 +15,28 @@ dependencies:
15
15
  requirements:
16
16
  - - "~>"
17
17
  - !ruby/object:Gem::Version
18
- version: 0.2.2
18
+ version: 0.2.3
19
19
  type: :runtime
20
20
  prerelease: false
21
21
  version_requirements: !ruby/object:Gem::Requirement
22
22
  requirements:
23
23
  - - "~>"
24
24
  - !ruby/object:Gem::Version
25
- version: 0.2.2
25
+ version: 0.2.3
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: itsi-server
28
28
  requirement: !ruby/object:Gem::Requirement
29
29
  requirements:
30
30
  - - "~>"
31
31
  - !ruby/object:Gem::Version
32
- version: 0.2.2
32
+ version: 0.2.3
33
33
  type: :runtime
34
34
  prerelease: false
35
35
  version_requirements: !ruby/object:Gem::Requirement
36
36
  requirements:
37
37
  - - "~>"
38
38
  - !ruby/object:Gem::Version
39
- version: 0.2.2
39
+ version: 0.2.3
40
40
  description: Wrapper Gem for both the Itsi server and the Itsi Fiber scheduler
41
41
  email:
42
42
  - wc@pico.net.nz
@@ -194,6 +194,8 @@ files:
194
194
  - docs/content/acknowledgements/_index.md
195
195
  - docs/content/configuration/_index.md
196
196
  - docs/content/contact/_index.md
197
+ - docs/content/directory_listing.jpg
198
+ - docs/content/error_page.jpg
197
199
  - docs/content/faqs/_index.md
198
200
  - docs/content/features/_index.md
199
201
  - docs/content/getting_started/_index.md
@@ -215,7 +217,6 @@ files:
215
217
  - docs/go.mod
216
218
  - docs/go.sum
217
219
  - docs/hugo.yaml
218
- - examples/static_assets_example.rb
219
220
  - fairytale.txt
220
221
  - gems/scheduler/.gitignore
221
222
  - gems/scheduler/.rubocop.yml
@@ -565,11 +566,6 @@ files:
565
566
  - gems/server/test/options/test_threads.rb
566
567
  - gems/server/test/options/test_workers.rb
567
568
  - gems/server/test/rack/test_rack_server.rb
568
- - grpc_test/Itsi.rb
569
- - grpc_test/echo.proto
570
- - grpc_test/echo_pb.rb
571
- - grpc_test/echo_service_impl.rb
572
- - grpc_test/echo_services_pb.rb
573
569
  - itsi-scheduler-100.png
574
570
  - itsi-server-100.png
575
571
  - lib/itsi.rb
@@ -580,8 +576,8 @@ licenses:
580
576
  - MIT
581
577
  metadata:
582
578
  homepage_uri: https://itsi.fyi
583
- source_code_uri: https://github.com/woutercoppieters/itsi
584
- changelog_uri: https://github.com/woutercoppieters/itsi/blob/main/CHANGELOG.md
579
+ source_code_uri: https://github.com/wouterken/itsi
580
+ changelog_uri: https://github.com/wouterken/itsi/blob/main/CHANGELOG.md
585
581
  rdoc_options: []
586
582
  require_paths:
587
583
  - lib
@@ -1,83 +0,0 @@
1
- # Example of how to use the Static Assets middleware in Itsi.rb
2
-
3
- workers 1
4
- threads 1
5
- bind 'http://localhost:3000'
6
-
7
- # Example 1: Using the "alias" behavior (default)
8
- # With alias behavior, if you access /assets/image.png, it looks for the file at public/assets/image.png
9
- location '/assets' do
10
- # Serve static files from the "public/assets" directory
11
- static_assets root_dir: "public/assets",
12
- # Default behavior is "alias" - the location pattern is stripped from the path
13
- # root_is_prefix: false, # This is the default, so we don't need to specify it
14
- # Only allow certain file extensions
15
- allowed_extensions: %w[css js jpg jpeg png gif svg ico woff woff2 ttf otf html],
16
- # Return a 404 error if file is not found
17
- not_found: 'error',
18
- # Enable auto-indexing of directories
19
- auto_index: true,
20
- # Try adding .html extension to extensionless URLs
21
- try_html_extension: true,
22
- # Files under this size are cached in memory
23
- max_file_size_in_memory: 1024 * 1024, # 1MB
24
- # Maximum number of files to keep in memory cache
25
- max_files_in_memory: 1000,
26
- # Check for file modifications every 5 seconds
27
- file_check_interval: 5,
28
- # Add custom headers to all responses
29
- headers: {
30
- 'Cache-Control' => 'public, max-age=86400',
31
- 'X-Content-Type-Options' => 'nosniff'
32
- }
33
- end
34
-
35
- # Example 2: Using the "root" behavior
36
- # With root behavior, if you access /static/image.png, it looks for the file at public/static/image.png
37
- location '/static' do
38
- # Serve static files from the "public" directory
39
- static_assets root_dir: "public",
40
- # Use "root" behavior - keep the location pattern as part of the path
41
- root_is_prefix: true,
42
- not_found: 'error',
43
- auto_index: true
44
- end
45
-
46
- # Example 3: Serving a Single Page Application (SPA)
47
- location '/app' do
48
- static_assets root_dir: "public/app",
49
- # If file is not found, serve index.html (typical SPA behavior)
50
- not_found: "index", # equivalent to not_found: { index: "index.html" }
51
- headers: {
52
- 'Cache-Control' => 'public, max-age=3600'
53
- }
54
- end
55
-
56
- # Example 4: Using file_server as an alias for static_assets
57
- location '/public' do
58
- file_server root_dir: "public",
59
- auto_index: true,
60
- not_found: "fallthrough"
61
- end
62
-
63
- # Example of a restricted files area
64
- location '/downloads' do
65
- # Basic authentication before serving files
66
- auth_basic realm: 'Downloads Area', credential_pairs: { 'user' => 'password' }
67
-
68
- # Serve files after authentication
69
- static_assets root_dir: 'private/downloads',
70
- # Only allow PDF files
71
- allowed_extensions: ['pdf'],
72
- # If file is not found, fall through to the next middleware
73
- not_found: 'fallthrough'
74
- end
75
-
76
- # Example of redirecting to another location if file is not found
77
- location '/docs' do
78
- static_assets root_dir: 'documentation',
79
- # Redirect to documentation homepage if file not found
80
- not_found: 'redirect', # equivalent to not_found: { redirect: "/docs/index.html" }
81
- # Don't cache these files in memory
82
- max_file_size_in_memory: 0
83
- end
data/grpc_test/Itsi.rb DELETED
@@ -1,11 +0,0 @@
1
- require "grpc"
2
- require_relative 'echo_service_impl'
3
-
4
- bind "http://localhost:3000"
5
-
6
- grpc EchoServiceImpl.new,
7
- nonblocking: false,
8
- compression: 'gzip' do
9
- # Nested middleware still works:
10
- response_headers additions: { 'X-Service' => ['Echo'] }
11
- end
data/grpc_test/echo.proto DELETED
@@ -1,14 +0,0 @@
1
- syntax = "proto3";
2
- package echo;
3
-
4
- service EchoService {
5
- rpc Echo(EchoRequest) returns (EchoResponse);
6
- }
7
-
8
- message EchoRequest {
9
- string message = 1;
10
- }
11
-
12
- message EchoResponse {
13
- string message = 1;
14
- }
data/grpc_test/echo_pb.rb DELETED
@@ -1,16 +0,0 @@
1
- # frozen_string_literal: true
2
- # Generated by the protocol buffer compiler. DO NOT EDIT!
3
- # source: echo.proto
4
-
5
- require 'google/protobuf'
6
-
7
-
8
- descriptor_data = "\n\necho.proto\x12\x04\x65\x63ho\"\x1e\n\x0b\x45\x63hoRequest\x12\x0f\n\x07message\x18\x01 \x01(\t\"\x1f\n\x0c\x45\x63hoResponse\x12\x0f\n\x07message\x18\x01 \x01(\t2<\n\x0b\x45\x63hoService\x12-\n\x04\x45\x63ho\x12\x11.echo.EchoRequest\x1a\x12.echo.EchoResponseb\x06proto3"
9
-
10
- pool = Google::Protobuf::DescriptorPool.generated_pool
11
- pool.add_serialized_file(descriptor_data)
12
-
13
- module Echo
14
- EchoRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("echo.EchoRequest").msgclass
15
- EchoResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("echo.EchoResponse").msgclass
16
- end
@@ -1,8 +0,0 @@
1
- require_relative 'echo_services_pb'
2
-
3
- class EchoServiceImpl < Echo::EchoService::Service
4
- # Unary RPC implementation
5
- def echo(req, _unused_call)
6
- Echo::EchoResponse.new(message: req.message)
7
- end
8
- end
@@ -1,22 +0,0 @@
1
- # Generated by the protocol buffer compiler. DO NOT EDIT!
2
- # Source: echo.proto for package 'echo'
3
-
4
- require 'grpc'
5
- require_relative 'echo_pb'
6
-
7
- module Echo
8
- module EchoService
9
- class Service
10
-
11
- include ::GRPC::GenericService
12
-
13
- self.marshal_class_method = :encode
14
- self.unmarshal_class_method = :decode
15
- self.service_name = 'echo.EchoService'
16
-
17
- rpc :Echo, ::Echo::EchoRequest, ::Echo::EchoResponse
18
- end
19
-
20
- Stub = Service.rpc_stub_class
21
- end
22
- end