IDL Types & Fields
PulseRPC supports a rich type system for defining your service contracts.
Built-in Types
| IDL Type | Description | Go | Java | Python | TypeScript |
|---|---|---|---|---|---|
string |
Text/UTF-8 strings | string |
String |
str |
string |
int |
64-bit integers | int64 |
Long |
int |
number |
float |
64-bit floating point | float64 |
Double |
float |
number |
bool |
Boolean values | bool |
Boolean |
bool |
boolean |
Arrays
Ordered lists of a type:
struct Cart {
items []CartItem
tags []string
}
Language mapping:
- Go:
[]T - Java:
List<T> - Python:
List[T] - TypeScript:
T[]
Maps
Key-value dictionaries (keys are always strings):
struct Metadata {
tags map[string]string
headers map[string]string
}
Language mapping:
- Go:
map[string]T - Java:
Map<String, T> - Python:
Dict[str, T] - TypeScript:
Record<string, T>
Optional Fields
Fields marked [optional] can be null or omitted:
struct User {
userId string
email string
phone string [optional] // Can be null
bio string [optional] // Can be omitted
}
Validation rules:
- Required fields must be present and non-null
- Optional fields can be omitted or null
- Arrays/maps are optional if their element type is optional
Struct Inheritance
Extend existing structs to reuse fields:
struct BaseResponse {
status string
message string
}
struct UserResponse extends BaseResponse {
user User
}
// UserResponse has: status, message, user
Rules:
- Child struct inherits all parent fields
- Can add new fields
- Multiple inheritance not supported
Complex Example
namespace ecommerce
enum ContactType {
email
phone
sms
}
struct Contact {
type ContactType
value string
}
struct Address {
street string
city string
state string
zipCode string
country string
isPrimary bool [optional]
}
struct User {
userId string
name string
email string
contacts []Contact
metadata map[string]string
address Address [optional]
createdAt int
verified bool
}
Type Validation
PulseRPC runtimes automatically validate:
- Required fields are present
- Types match (string, int, float, bool)
- Arrays contain correct element types
- Maps have string keys and correct value types
See Validation for details.
Next Steps
- Validation - How runtime validation works
- Syntax - Complete IDL syntax reference
- Quickstart - Hands-on practice