Skip to content

Commit 979f964

Browse files
Better naming conventions.
1 parent 0d24ff4 commit 979f964

33 files changed

+410
-378
lines changed

context/best-practices.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ Place environments in `lib/my_library/environment/`:
6161
module MyLibrary
6262
module Environment
6363
module WebEnvironment
64-
include Async::Service::Managed::Environment
64+
include Async::Service::ManagedEnvironment
6565

6666
def service_class
6767
MyLibrary::Service::WebService
@@ -87,7 +87,7 @@ Place services in `lib/my_library/service/`:
8787
# lib/my_library/service/web_service.rb
8888
module MyLibrary
8989
module Service
90-
class WebService < Async::Service::Managed::Service
90+
class WebService < Async::Service::ManagedService
9191
private def format_title(evaluator, server)
9292
if server&.respond_to?(:connection_count)
9393
"#{self.name} [#{evaluator.host}:#{evaluator.port}] (#{server.connection_count} connections)"
@@ -114,11 +114,11 @@ end
114114

115115
### Use `Managed::Environment` for Services
116116

117-
Include {ruby Async::Service::Managed::Environment} for services that need robust lifecycle management using {ruby Async::Service::Managed::Service}:
117+
Include {ruby Async::Service::ManagedEnvironment} for services that need robust lifecycle management using {ruby Async::Service::ManagedService}:
118118

119119
```ruby
120120
module WebEnvironment
121-
include Async::Service::Managed::Environment
121+
include Async::Service::ManagedEnvironment
122122

123123
def service_class
124124
WebService
@@ -201,10 +201,10 @@ end
201201

202202
### Use `Managed::Service` as Base Class
203203

204-
Prefer `Async::Service::Managed::Service` over `Generic` for most services:
204+
Prefer `Async::Service::ManagedService` over `GenericService` for most services:
205205

206206
```ruby
207-
class WebService < Async::Service::Managed::Service
207+
class WebService < Async::Service::ManagedService
208208
# Managed::Service automatically handles:
209209
# - Container setup with proper options.
210210
# - Health checking with process title updates.
@@ -247,7 +247,7 @@ Try to keep process titles short and focused.
247247
Utilize the `start` and `stop` hooks to manage shared resources effectively:
248248

249249
```ruby
250-
class WebService < Async::Service::Managed::Service
250+
class WebService < Async::Service::ManagedService
251251
def start
252252
# Bind to the endpoint in the container:
253253
@endpoint = @evaluator.endpoint.bind

context/deployment.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ Let's start with a simple HTTP service that we'll deploy:
1111
# frozen_string_literal: true
1212

1313
require "async/http"
14-
require "async/service/managed/service"
15-
require "async/service/managed/environment"
14+
require "async/service/managed_service"
15+
require "async/service/managed_environment"
1616

17-
class WebService < Async::Service::Managed::Service
17+
class WebService < Async::Service::ManagedService
1818
def start
1919
super
2020
@endpoint = @evaluator.endpoint
@@ -40,7 +40,7 @@ class WebService < Async::Service::Managed::Service
4040
end
4141

4242
module WebEnvironment
43-
include Async::Service::Managed::Environment
43+
include Async::Service::ManagedEnvironment
4444

4545
def endpoint
4646
Async::HTTP::Endpoint.parse("http://0.0.0.0:3000")

context/getting-started.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@ $ bundle add async-service
1414

1515
`async-service` has several core concepts:
1616

17-
- A {ruby Async::Service::Generic} which represents the base class for implementing services.
17+
- A {ruby Async::Service::GenericService} which represents the base class for implementing services.
1818
- A {ruby Async::Service::Configuration} which manages service configurations and environments.
1919
- A {ruby Async::Service::Controller} which handles starting, stopping, and managing services.
2020

2121
## Usage
2222

23-
Services are long-running processes that can be managed as a group. Each service extends `Async::Service::Generic` and implements a `setup` method that defines how the service runs.
23+
Services are long-running processes that can be managed as a group. Each service extends `Async::Service::GenericService` and implements a `setup` method that defines how the service runs.
2424

2525
### Basic Service
2626

@@ -31,7 +31,7 @@ Create a simple service that runs continuously:
3131

3232
require "async/service"
3333

34-
class HelloService < Async::Service::Generic
34+
class HelloService < Async::Service::GenericService
3535
def setup(container)
3636
super
3737

@@ -73,7 +73,7 @@ end
7373
In your service implementation, you can access these values through the environment and evaluator:
7474

7575
```ruby
76-
class WebServerService < Async::Service::Generic
76+
class WebServerService < Async::Service::GenericService
7777
def setup(container)
7878
super
7979

@@ -103,7 +103,7 @@ You can define multiple services in a single configuration file:
103103

104104
require "async/service"
105105

106-
class WebService < Async::Service::Generic
106+
class WebService < Async::Service::GenericService
107107
def setup(container)
108108
super
109109

@@ -115,7 +115,7 @@ class WebService < Async::Service::Generic
115115
end
116116
end
117117

118-
class WorkerService < Async::Service::Generic
118+
class WorkerService < Async::Service::GenericService
119119
def setup(container)
120120
super
121121

context/service-architecture.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -82,14 +82,14 @@ end
8282

8383
## Service
8484

85-
The {ruby Async::Service::Generic} represents the service implementation layer. It handles the actual business logic of your services, provides access to configuration through environment evaluators, and manages the service lifecycle including startup, execution, and shutdown phases.
85+
The {ruby Async::Service::GenericService} represents the service implementation layer. It handles the actual business logic of your services, provides access to configuration through environment evaluators, and manages the service lifecycle including startup, execution, and shutdown phases.
8686

8787
### Business Logic
8888

8989
Services contain the actual implementation of what your service does:
9090

9191
```ruby
92-
class WebService < Async::Service::Generic
92+
class WebService < Async::Service::GenericService
9393
def setup(container)
9494
super
9595

@@ -148,7 +148,7 @@ By evaluating the log_path in the child process, you ensure that each instance h
148148
Services define their startup, running, and shutdown behavior:
149149

150150
```ruby
151-
class MyService < Async::Service::Generic
151+
class MyService < Async::Service::GenericService
152152
def start
153153
super
154154
# Service-specific startup logic including pre-loading libraries and binding to network interfaces before forking.
@@ -262,7 +262,7 @@ end
262262

263263
### Health Checking
264264

265-
For services using `Async::Service::Managed::Service`, health checking is handled automatically. For services extending `Generic`, you can set up health checking manually:
265+
For services using `Async::Service::ManagedService`, health checking is handled automatically. For services extending `GenericService`, you can set up health checking manually:
266266

267267
```ruby
268268
def setup(container)
@@ -284,7 +284,7 @@ def setup(container)
284284
end
285285
```
286286

287-
Note: `Async::Service::Managed::Service` automatically handles health checking, container options, and process title formatting, so you typically don't need to set this up manually.
287+
Note: `Async::Service::ManagedService` automatically handles health checking, container options, and process title formatting, so you typically don't need to set this up manually.
288288

289289
## How They Work Together
290290

@@ -305,7 +305,7 @@ end
305305

306306
```ruby
307307
# Services are defined using environments:
308-
class WebService < Async::Service::Generic
308+
class WebService < Async::Service::GenericService
309309
def setup(container)
310310
super
311311

@@ -440,7 +440,7 @@ Create reusable configuration modules:
440440

441441
```ruby
442442
module ManagedEnvironment
443-
include Async::Service::Managed::Environment
443+
include Async::Service::ManagedEnvironment
444444

445445
def count
446446
4
@@ -464,7 +464,7 @@ end
464464
Build service hierarchies:
465465

466466
```ruby
467-
class BaseWebService < Async::Service::Generic
467+
class BaseWebService < Async::Service::GenericService
468468
def setup(container)
469469
super
470470
# Common web service setup

examples/deployment/server.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
# frozen_string_literal: true
33

44
require "async/http"
5-
require "async/service/managed/service"
6-
require "async/service/managed/environment"
5+
require "async/service/managed_service"
6+
require "async/service/managed_environment"
77

8-
class WebService < Async::Service::Managed::Service
8+
class WebService < Async::Service::ManagedService
99
def start
1010
super
1111
@endpoint = @evaluator.endpoint
@@ -31,7 +31,7 @@ def run(instance, evaluator)
3131
end
3232

3333
module WebEnvironment
34-
include Async::Service::Managed::Environment
34+
include Async::Service::ManagedEnvironment
3535

3636
def endpoint
3737
Async::HTTP::Endpoint.parse("http://0.0.0.0:3000")

examples/hello/hello.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# Released under the MIT License.
55
# Copyright, 2024-2025, by Samuel Williams.
66

7-
class SleepService < Async::Service::Generic
7+
class SleepService < Async::Service::GenericService
88
def setup(container)
99
super
1010

examples/hello/readme.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ Press `Ctrl+C` to stop the service.
2727
The example defines a simple service class:
2828

2929
~~~ ruby
30-
class SleepService < Async::Service::Generic
30+
class SleepService < Async::Service::GenericService
3131
def setup(container)
3232
super
3333

@@ -45,7 +45,7 @@ end
4545

4646
Key points:
4747

48-
- **Inherits from `Async::Service::Generic`**: Provides the basic service interface
48+
- **Inherits from `Async::Service::GenericService`**: Provides the basic service interface
4949
- **Implements `setup(container)`**: Defines how the service runs
5050
- **Uses `container.run`**: Creates one instance with automatic restart
5151
- **Calls `instance.ready!`**: Signals the service is ready

examples/ipc/client.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
ipc_socket_path File.expand_path("service.ipc", Dir.pwd)
1717
end
1818

19-
class IPCClient < Async::Service::Generic
19+
class IPCClient < Async::Service::GenericService
2020
def setup(container)
2121
super
2222

examples/ipc/server.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
ipc_socket_path File.expand_path("service.ipc", Dir.pwd)
1616
end
1717

18-
class IPCServer < Async::Service::Generic
18+
class IPCServer < Async::Service::GenericService
1919
def setup(container)
2020
super
2121

examples/ipc/service.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66

77
require "socket"
88
require "async"
9-
require "async/service/managed/service"
10-
require "async/service/managed/environment"
9+
require "async/service/managed_service"
10+
require "async/service/managed_environment"
1111

1212
# Server service that listens on a Unix domain socket and responds with "Hello World"
13-
class IPCServer < Async::Service::Managed::Service
13+
class IPCServer < Async::Service::ManagedService
1414
def run(instance, evaluator)
1515
socket_path = evaluator.ipc_socket_path
1616

@@ -47,7 +47,7 @@ def run(instance, evaluator)
4747
end
4848

4949
# Client service that periodically connects to the server
50-
class IPCClient < Async::Service::Managed::Service
50+
class IPCClient < Async::Service::ManagedService
5151
def run(instance, evaluator)
5252
socket_path = evaluator.ipc_socket_path
5353
timeout = evaluator.ipc_connection_timeout
@@ -88,7 +88,7 @@ def run(instance, evaluator)
8888
end
8989

9090
module IPCEnvironment
91-
include Async::Service::Managed::Environment
91+
include Async::Service::ManagedEnvironment
9292

9393
def ipc_socket_path
9494
File.expand_path("service.ipc", Dir.pwd)

0 commit comments

Comments
 (0)