processor

package
v1.54.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 3, 2025 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package processor provides client functionality for the Agones allocation processor system

The allocation processor system enables batched game server allocation requests This package contains the client implementation that connects to the processor service batches allocation requests, and handles the stream-based communication protocol

Key components: - Client: Manages connection lifecycle and request batching - Config: Configuration for processor client behavior - Batch handling: Accumulates requests and sends them in batches to the processor

The client establishes a bidirectional gRPC stream with the processor service, registers itself, and then handles pull requests (to send batched allocations) and batch responses (containing allocation results)

Flow diagram:

┌─────────────────┐    ┌─────────────────────┐    ┌─────────────────────┐
│     Client      │    │  Processor Client   │    │  Processor Server   │
│  (Allocator/    │    │   (this package)    │    │                     │
│   Extension)    │    │                     │    │                     │
└─────────────────┘    └─────────────────────┘    └─────────────────────┘
         │                        │                          │
         │                        │ 1. Connect & Register    │
         │                        │    (bidirectional stream)│
         │                        ├──────────────────────────►
         │                        │                          │
         │ 2. Allocate(request)   │                          │
         ├────────────────────────►                          │
         │                        │                          │
         │                        │ 3. Add to hotBatch       │
         │                        │    (accumulate)          │
         │                        │                          │
         │                        │ 4. Pull Request          │
         │                        │    (to all clients)      │
         │                        ◄──────────────────────────┤
         │                        │ 5. Send BatchRequest     │
         │                        │    (hotBatch)            │
         │                        ├──────────────────────────►
         │                        │                          │
         │                        │                          │ 6. Process
         │                        │                          │    allocations
         │                        │                          │
         │                        │ 7. BatchResponse         │
         │                        │    (results)             │
         │                        ◄──────────────────────────┤
         │ 8. Return result       │                          │
         ◄────────────────────────┤                          │
         │                        │                          │

Note: Multiple Processor Clients can connect to one Processor Server
      The server sends pull requests to all connected clients

Legend:
- Client: Makes allocation requests (allocator, extensions, etc.)
- Processor Client: Batches requests and manages communication
- Processor Server: Processes batched allocations from multiple clients
- Pull Request: Server asks all connected clients for pending requests
- BatchRequest: Client sends accumulated allocation requests
- BatchResponse: Server returns allocation results

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client interface {
	// Run starts the processor client
	Run(ctx context.Context) error

	// Allocate performs a batch allocation request
	Allocate(ctx context.Context, req *allocationpb.AllocationRequest) (*allocationpb.AllocationResponse, error)
}

Client interface for allocation operations Provides methods to run the processor client and perform allocation requests

func NewClient

func NewClient(config Config, logger logrus.FieldLogger) Client

NewClient creates a new processor client

type Config

type Config struct {
	// ClientID is a unique identifier for this processor client instance
	ClientID string

	// ProcessorAddress specifies the address of the processor service to connect to
	ProcessorAddress string

	// MaxBatchSize determines the maximum number of allocation requests to batch together
	MaxBatchSize int

	// AllocationTimeout is the maximum duration to wait for an allocation response
	AllocationTimeout time.Duration

	// ReconnectInterval is the time to wait before retrying a failed connection
	ReconnectInterval time.Duration
}

Config holds the processor client configuration

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL