Define service architecture

Service architecture refers to how services are composed and how they communicate with other components in the system.

Create service bundles

Service bundles group related service units that can be deployed together. The only property that's required for a service bundle is a name. Together with the package name, the name forms the fully qualified name of the service bundle.

Service bundles are defined with Vehicle Services Interface Definition Language (VSIDL) files (files with the extension of .vsidl).

The following example shows two service bundles: a TirePressureMonitoring service bundle and a BodyControl service bundle:

package: "com.android.sdv.sample.vsidl"

service_bundle {
  name: "TirePressureMonitoring"
}

service_bundle {
  name: "BodyControl"
}

Where:

  • service_bundle identifies the structure as a service bundle.
  • name is the name of the service bundle.

Messaging patterns: Pub/Sub and RPC

The SDV framework uses two primary messaging patterns: Publish-Subscribe (Pub/Sub) and remote procedure call (RPC).

In Pub/Sub, the system reacts to the evolving state of the vehicle by streaming data to any interested components. Data is organized into topics. Publishers send messages on topics. The publisher sends messages on topics without needing to know which (or how many) subscribers are listening. Subscribers receive messages on topics without knowing which exact publishers sent the messages.

In contrast, RPC is designed for action and outcome. It is used when the caller initiates a request because they care about the specific result or confirmation of that action. The caller invokes a specific method on a channel.

While these patterns serve different operational needs, they share a common structural property: both rely on named communication paths-topics for Pub/Sub and channels for RPC—to decouple the identity of the sender from the receiver.

Declare publisher and subscriber

Publish-subscribe is a messaging pattern where senders of messages, called publishers, don't send the messages directly to specific receivers, called subscribers. Instead, publishers categorize messages into topics and subscribers subscribe to one or more communication topics and receive only messages that are published to those topics. For further information on publish-subscribe, see Publish-subscribe pattern.

Add a publisher to a service bundle

The following examples shows a publisher added to the TirePressureMonitoring service bundle:

package: "com.android.sdv.sample.vsidl"

service_bundle {
  name: "TirePressureMonitoring"

  publisher {
    message: "TirePressure"
    topic: "front-left"
    capacity: 10
  }

}

service_bundle {
  name: "BodyControl"

  ...
}

Where:

  • publisher Service message publishes messages to a message queue.
  • message Data structure or message type defined in protobuf (file with the .protobuf extension).
  • topic Unique identifier for the publication topic. It must be in lowercase dash-case.
  • capacity Number of messages the publication queue can hold. It must be an even number greater than or equal to 2.

Add a subscribe to a service bundle

The following examples shows a publisher added to the BodyControl service bundle:

package: "com.android.sdv.sample.vsidl"

service_bundle {
  name: "TirePressureMonitoring"

  publisher {
    message: "TirePressure"
    topic: "front-left"
    capacity: 10
  }
}

service_bundle {
  name: "BodyControl"

  subscriber {
    message: "com.android.sdv.sample.vsidl.TirePressure"
    topic: "front-left"
  }
}

Where:

  • subscriber Service bundle subscribes to topics.
  • message Data structure or message type defined in protobuf (file with the .protobuf extension).
  • topic Unique identifier for the publication topic. It must match the publisher's topic and be in lowercase dash-case.

Define RPC clients and servers

Remote procedure call (RPC) provides location independence of function calls. In this pattern, the channel serves as the named rendezvous point where the client and provider meet. By targeting the channel rather than a specific service instance, the framework decouples the intent of the command from the physical location of the implementation.

The following example designates the ClimateControl service bundle as a server and the BodyControl service bundle as a client:

package: "com.sdv.cc"

service_bundle {
  name: "ClimateControl"

  server {
    service: "SetTemperature"
    channel: "climate-control"
  }
}

service_bundle {
  name: "BodyControl"

  client {
    service: "SetTemperature"
    channel: "climate-control"
  }
}

Where:

  • server indicates that the service bundle is a server that provides some RPC service (identified by service as SetTemperature).
  • client indicates that the service bundle is a client that invokes the SetTemperature service.
  • channel is the name of the RPC channel. It must be in lowercase dash-case and unique per service.

This example allows the BodyControl service bundle to make remote procedure calls to the ClimateControl service bundle to set the temperature.

What's next

After defining your architecture, generate middleware code.