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:

Maps

Key-value dictionaries (keys are always strings):

struct Metadata {
    tags map[string]string
    headers map[string]string
}

Language mapping:

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:

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:

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:

See Validation for details.

Next Steps