---
source: https://iinventedlight.com/library/notes/grpc-service-definition.md
title: "gRPC services are defined in .proto files with four kinds of RPC methods"
license: CC-BY-4.0
license_url: https://creativecommons.org/licenses/by/4.0/
source_license: "CC-BY-4.0 (gRPC docs); CC-BY-4.0 (grpc/grpc.io (GitHub)); prose restates cited source lines in own words"
license_family: mixed-green
attribution: "Summary by iinventedlight (AI-assisted). Sources: gRPC docs, Core concepts, architecture and lifecycle; grpc/grpc.io (GitHub), core-concepts.md (source page). CC-BY-4.0 (https://raw.githubusercontent.com/grpc/grpc.io/main/LICENSE). Copyright gRPC Authors."
author: "iinventedlight (synthesis of cited sources); text drafted with AI assistance"
date: 2026-11-18
status: published
approved_by: "Cole Withington, 2026-11-20 13:14 PT: \"Publish the full batch and rewrite the 6 live notes\""
checked_on: 2026-11-18
as_of: 2026-11-18
confidence: medium
untested: "Not reproduced (2026-11-18). Official docs and source files were read; no test suite, server, or API call was run for this note."
category: coding-references
topic_area: "code-web: grpc service definition"
tags: [grpc, protobuf, rpc, streaming, deadlines, api]
client: Librarian
sources:
  - id: S1
    title: "Core concepts, architecture and lifecycle"
    publisher: gRPC docs
    url: https://grpc.io/docs/what-is-grpc/core-concepts/
    accessed: 2026-11-18
    license: "CC-BY-4.0"
  - id: S2
    title: "core-concepts.md (source page)"
    publisher: grpc/grpc.io (GitHub)
    url: https://github.com/grpc/grpc.io/blob/main/content/en/docs/what-is-grpc/core-concepts.md
    accessed: 2026-11-18
    license: "CC-BY-4.0"
---
# gRPC services are defined in .proto files with four kinds of RPC methods
**Answer:** Define a service in a `.proto` file, specifying the methods that can be called remotely with their parameters and return types. Protocol buffers are the default Interface Definition Language (IDL) for the service interface and the payload messages.

## Example

```proto
service HelloService {
  rpc SayHello (HelloRequest) returns (HelloResponse);
  rpc LotsOfReplies (HelloRequest) returns (stream HelloResponse);
  rpc LotsOfGreetings (stream HelloRequest) returns (HelloResponse);
  rpc BidiHello (stream HelloRequest) returns (stream HelloResponse);
}

message HelloRequest { string greeting = 1; }
message HelloResponse { string reply = 1; }
```

## The four kinds of method

| Kind | Messages |
|---|---|
| Unary | the client sends a single request and gets a single response back, just like a normal function call |
| Server streaming | the client sends a request and reads a stream of messages back until there are no more |
| Client streaming | the client writes a sequence of messages, then waits for the server's single response |
| Bidirectional streaming | both sides send a sequence of messages using a read-write stream |

gRPC guarantees message ordering within an individual RPC call. In bidirectional streaming the two streams operate independently, and either side may read and write in whatever order it likes.

## Lifecycle rules

- Clients can specify how long they are willing to wait; the RPC is then terminated with a `DEADLINE_EXCEEDED` error.
- Either the client or the server can cancel an RPC at any time, and changes made before a cancellation are not rolled back.

## See also

- [protobuf-message-types](https://iinventedlight.com/library/notes/protobuf-message-types/)
- [http-status-codes](https://iinventedlight.com/library/notes/http-status-codes/)

## Claims

- id: C1
  claim: gRPC uses protocol buffers as its IDL by default.
  source: S1
  evidence: "By default, gRPC uses protocol buffers as the Interface Definition Language (IDL)"

- id: C2
  claim: gRPC guarantees message ordering within an individual RPC call.
  source: S2
  evidence: "gRPC guarantees message ordering within an individual RPC call."

- id: C3
  claim: Changes before a cancellation are not rolled back.
  source: S2
  evidence: "Changes made before a cancellation are not rolled back."

## Sources

- [S1] Core concepts, architecture and lifecycle. gRPC docs. https://grpc.io/docs/what-is-grpc/core-concepts/ . License: CC-BY-4.0. Accessed 2026-11-18.

- [S2] core-concepts.md (source page). grpc/grpc.io (GitHub). https://github.com/grpc/grpc.io/blob/main/content/en/docs/what-is-grpc/core-concepts.md . License: CC-BY-4.0. Accessed 2026-11-18.

License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: gRPC docs, Core concepts, architecture and lifecycle; grpc/grpc.io (GitHub), core-concepts.md (source page). CC-BY-4.0 (https://raw.githubusercontent.com/grpc/grpc.io/main/LICENSE). Copyright gRPC Authors. Text was condensed and changed from the originals.

---

Agents: [/agents.md](/agents.md) | [/.well-known/agent-library.json](/.well-known/agent-library.json).
