docs/guides/microservices-thrift.md
Use this guide when several repositories communicate through Apache Thrift and you want GitNexus to trace impact across provider and consumer boundaries. The walkthrough assumes each service is indexed on its own, then joined through a GitNexus group.
This is not a framework integration guide. GitNexus reads portable Thrift IDL and common Java generated-code shapes. Framework-specific wiring, service discovery, deployment metadata, and private annotations belong outside the open-source core.
.thrift files define the canonical service contract. A method in an IDL service becomes a stable contract id in the form thrift::<namespace>.<Service>/<Method>.thrift::<namespace>.<Service>/* are supported as manifest and matching fallback forms when a service-level link is needed.Service.Iface; consumers commonly hold or construct generated service interfaces or clients.namespace java billing.v1
struct PlaceOrderRequest {
1: string orderId
2: double amount
}
struct PlaceOrderResponse {
1: bool accepted
}
struct GetOrderRequest {
1: string orderId
}
struct GetOrderResponse {
1: string orderId
2: string status
}
service OrderService {
PlaceOrderResponse PlaceOrder(1: PlaceOrderRequest request)
GetOrderResponse GetOrder(1: GetOrderRequest request)
}
The service methods above produce canonical ids:
thrift::billing.v1.OrderService/PlaceOrderthrift::billing.v1.OrderService/GetOrderthrift::billing.v1.OrderService/* as a service-level manifest or matching fallback formGenerated Java code usually exposes an Iface interface for the service. A provider implementation can be detected when it implements that generated interface.
package example.billing;
import billing.v1.GetOrderRequest;
import billing.v1.GetOrderResponse;
import billing.v1.OrderService;
import billing.v1.PlaceOrderRequest;
import billing.v1.PlaceOrderResponse;
public final class OrderServiceHandler implements OrderService.Iface {
@Override
public PlaceOrderResponse PlaceOrder(PlaceOrderRequest request) {
return new PlaceOrderResponse(true);
}
@Override
public GetOrderResponse GetOrder(GetOrderRequest request) {
return new GetOrderResponse(request.getOrderId(), "CREATED");
}
}
With the IDL available, GitNexus can connect the implementation to thrift::billing.v1.OrderService/PlaceOrder and thrift::billing.v1.OrderService/GetOrder.
Consumers are strongest when Java usage can be tied back to the IDL namespace and service.
package example.checkout;
import billing.v1.OrderService;
import billing.v1.PlaceOrderRequest;
public final class CheckoutWorkflow {
private final OrderService.Iface orders;
public CheckoutWorkflow(OrderService.Iface orders) {
this.orders = orders;
}
public void submit(String orderId) throws Exception {
orders.PlaceOrder(new PlaceOrderRequest(orderId, 42.0));
}
}
Some generated-code styles use the generated service type directly while keeping enough IDL context through imports and method calls.
package example.reporting;
import billing.v1.GetOrderRequest;
import billing.v1.OrderService;
public final class OrderLookup {
private final OrderService.Client client;
public OrderLookup(OrderService.Client client) {
this.client = client;
}
public String status(String orderId) throws Exception {
return client.GetOrder(new GetOrderRequest(orderId)).getStatus();
}
}
When IDL context is missing, GitNexus may still emit a weaker consumer signal for generated Iface or Client shapes, but confidence is lower.
New group configs enable Thrift contract detection by default. Keep detect.thrift: true
when a group should scan for Thrift contracts, or set it to false to skip Thrift
extraction for that group.
version: 1
name: billing-platform
description: Fictional services connected by Apache Thrift
repos:
checkout: checkout-service
billing: billing-service
links: []
detect:
http: true
grpc: false
thrift: true
topics: false
shared_libs: true
To disable Thrift extraction explicitly:
detect:
thrift: false
After indexing each member repository, run group sync to extract contracts and write cross-repo links:
npx gitnexus group sync billing-platform
Use manifest links when automatic extraction cannot see a provider or consumer, or when generated code is wrapped behind an abstraction. Write the contract without the thrift:: prefix; GitNexus canonicalizes it to the full Thrift contract id.
links:
- from: checkout
to: billing
type: thrift
contract: billing.v1.OrderService/PlaceOrder
role: consumer
GitNexus canonicalizes that manifest entry to thrift::billing.v1.OrderService/PlaceOrder and uses it to connect the two repositories.
Iface and Client shapes.