How phisgr/gatling-grpc works
Project Type and Purpose
• This is a load testing plugin for Gatling that focuses on gRPC. The core functionality lets users express gRPC calls (requests, streams, dynamic payloads, etc.) as part of Gatling simulations.
• It is designed to work with code generation (from Protocol Buffers) and provides support for both ScalaPB (for Scala) and Java Protobuf classes.
Main Components
a. Core Plugin Library:
– The heart of the project is the gRPC DSL implementation (found mainly in the src/main/scala/com/github/phisgr/gatling/grpc directory).
– This includes the various action builders (e.g. GrpcCallActionBuilder and others) and supporting utilities (protocol marshallers, check support, stream handling).
b. Language-specific Bindings:
– The “gatling-grpc-kt” module contains bindings written in Kotlin to support both Java and Kotlin users.
– The “macro” module might contain Scala macros meant to provide syntactic sugar or compile‐time code generation.
c. Code Generation & Protobuf Integration:
– The project handles gRPC’s need for code generation from protobuf files. Directories like src/test/protobuf and bench/src/main/protobuf highlight this aspect.
– There is also integration with ScalaPB, which is set up via build.sbt and the companion instructions in the README.
d. Benchmarking & Testing:
– The “bench” module is dedicated to performance benchmarking and might include JMH tests (as evident from the “bench/src/main/scala/…” and the jmh directories in “gatling-grpc-kt/src/jmh”).
– The “src/test” directory contains functional tests and example simulations.
e. External Dependencies:
– Integration with the Gatling load testing engine itself, which provides the simulation and session management.
– Dependencies on language-specific tooling and build systems (SBT for Scala, Gradle for the Kotlin binding module).
Relationships and Data Flow
• Within the plugin, differentiate between the DSL that users write (simulation scripts) and the underlying gRPC call builders that actually generate the requests.
• Integration point where Protocol Buffers get converted into runtime objects using ScalaPB (or Java PB), and then used by DSL actions.
• How benchmarking (bench module) and JMH tests interact with or measure the performance of the core gRPC calls.
Architectural Patterns and Design Principles
• A layered/microservice-like separation is evident: simulation scripts (user-facing API) → DSL-to-gRPC request construction → gRPC transport interaction.
• There’s separation by language modules (Scala core component, Kotlin and Java bindings) that extend the overall architecture.
• Use of extension methods and dynamic payload generation (using ScalaPB lenses) to enable dynamic test scenarios.