@@ -11,9 +11,9 @@ Submit Queue consists of three main services:
1111## gRPC API
1212
1313Each service has its own proto definitions and exposes its own gRPC API:
14- - ** GatewayService ** : Gateway API with Ping method (port 8081)
15- - ** OrchestratorService ** : Orchestrator API with Ping method (port 8082)
16- - ** SpeculatorService ** : Speculator API with Ping method (port 8083)
14+ - ** SubmitQueueGateway ** : Gateway API with Ping method (port 8081)
15+ - ** SubmitQueueOrchestrator ** : Orchestrator API with Ping method (port 8082)
16+ - ** SubmitQueueSpeculator ** : Speculator API with Ping method (port 8083)
1717
1818### Quick Start
1919
@@ -41,7 +41,7 @@ make run-client-gateway MESSAGE="hello"
4141go run examples/client/gateway/main.go -message " hello"
4242
4343# Or using grpcurl
44- grpcurl -plaintext -d ' {"message": "hello"}' localhost:8081 uber.devexp.submitqueue.gateway.GatewayService /Ping
44+ grpcurl -plaintext -d ' {"message": "hello"}' localhost:8081 uber.devexp.submitqueue.gateway.SubmitQueueGateway /Ping
4545```
4646
4747For detailed instructions, see [ examples/README.md] ( examples/README.md ) .
@@ -50,6 +50,23 @@ For detailed instructions, see [examples/README.md](examples/README.md).
5050
5151See [ docs/architecture/STRUCTURE.md] ( docs/architecture/STRUCTURE.md ) for a detailed breakdown of the project structure.
5252
53+ ## Architecture
54+
55+ The project follows clean architecture principles with clear separation of concerns:
56+
57+ - ** Controllers** (` core/controller/ ` ): Pure business logic, independent of transport layer
58+ - Only depend on logger, metrics, and protobuf types
59+ - Example: ` PingController ` handles ping business logic
60+
61+ - ** Server Adapters** (` examples/server/ ` ): gRPC transport layer
62+ - Wrap controllers and implement gRPC service interfaces
63+ - Handle protocol-specific concerns (e.g., ` UnimplementedServiceServer ` )
64+
65+ - ** Observability** : Built-in logging and metrics
66+ - Structured logging with [ Zap] ( https://github.com/uber-go/zap )
67+ - Metrics collection with [ Tally] ( https://github.com/uber-go/tally )
68+ - Development servers use human-readable console logging
69+
5370## Development
5471
5572### Prerequisites
@@ -159,7 +176,6 @@ bazel build //...
159176
160177# Build specific components
161178bazel build //gateway/protopb
162- bazel build //gateway:gateway
163179bazel build //examples/server/gateway:gateway
164180bazel build //examples/client/gateway:gateway
165181
@@ -226,7 +242,8 @@ message PingResponse {
226242 string message = 1;
227243 string service_name = 2;
228244 int64 timestamp = 3;
229- string hostname = 4; // New field added
245+ string hostname = 4;
246+ string new_field = 5; // New field added
230247}
231248```
232249
@@ -240,8 +257,8 @@ make proto
240257# - gateway/protopb/gateway_grpc.pb.go
241258# - gateway/protopb/gateway.pb.yarpc.go
242259
243- # Now update the service implementation
244- # Edit gateway/core/controller/ping.go to populate the hostname field
260+ # Now update the controller implementation
261+ # Edit gateway/core/controller/ping.go to populate the new field in the PingResponse
245262```
246263
247264### Testing
@@ -261,7 +278,7 @@ make proto
2612783 . ** Or use grpcurl:**
262279 ``` bash
263280 grpcurl -plaintext -d ' {"message": "hello"}' \
264- localhost:8081 uber.devexp.submitqueue.gateway.GatewayService /Ping
281+ localhost:8081 uber.devexp.submitqueue.gateway.SubmitQueueGateway /Ping
265282 ```
266283
267284#### Testing All Services
@@ -299,7 +316,7 @@ make test
2993161 . ** Update the proto file:**
300317 ``` protobuf
301318 // In gateway/proto/gateway.proto
302- service GatewayService {
319+ service SubmitQueueGateway {
303320 rpc Ping(PingRequest) returns (PingResponse) {}
304321 rpc NewMethod(NewRequest) returns (NewResponse) {} // Add new method
305322 }
@@ -313,17 +330,44 @@ make test
313330 make proto
314331 ```
315332
316- 3 . ** Implement the method in the service:**
333+ 3 . ** Implement the method in the controller:**
334+ ``` go
335+ // In gateway/core/controller/ (create a new controller file)
336+ type NewController struct {
337+ logger *zap.Logger
338+ metricsScope tally.Scope
339+ }
340+
341+ func NewNewController (logger *zap .Logger , scope tally .Scope ) *NewController {
342+ if logger == nil {
343+ logger = zap.NewNop ()
344+ }
345+ if scope == nil {
346+ scope = tally.NoopScope
347+ }
348+ return &NewController{logger: logger, metricsScope: scope}
349+ }
350+
351+ func (c *NewController ) NewMethod (ctx context.Context, req *pb.NewRequest) (*pb.NewResponse, error) {
352+ // Business logic here
353+ c.logger .Info (" new method called" )
354+ c.metricsScope .Counter (" new_method_total" ).Inc (1 )
355+ // ...
356+ }
357+ ```
358+
359+ 4 . ** Create server wrapper in example:**
317360 ``` go
318- // In gateway/core/controller/ping.go (or create a new file)
319- func (s *PingServiceImpl ) NewMethod (ctx context.Context, req *pb.NewRequest) (*pb.NewResponse, error) {
320- // Implementation here
361+ // In examples/server/gateway/main.go
362+ // Add method delegation to GatewayServer struct:
363+ func (s *GatewayServer ) NewMethod (ctx context.Context, req *pb.NewRequest) (*pb.NewResponse, error) {
364+ return s.newController .NewMethod (ctx, req)
321365 }
322366 ```
323367
324- 4 . ** Update clients to call the new method**
368+ 5 . ** Update clients to call the new method**
325369
326- 5 . ** Rebuild and test:**
370+ 6 . ** Rebuild and test:**
327371 ``` bash
328372 make build
329373 ```
0 commit comments