Skip to main content
This section covers the configuration methods every plugin must implement: RateLimit() and LabelConfig().

Configuration methods

The ResourcePlugin interface requires three configuration methods: We’ll implement the first two now. DiscoveryFilters() is covered in Discovery filters.

RateLimit

SFTP servers typically limit concurrent connections. The RateLimit() method tells formae how fast it can send requests to your plugin.

Configuration fields

Choosing a rate limit

Consider your target system’s limits:
  • SFTP servers: Often allow 5-10 concurrent connections
  • Cloud APIs: Check the provider’s documentation (AWS: varies by service, typically 10-100 RPS)
  • SaaS APIs: Usually documented in API docs (e.g., “100 requests per minute”)
For our SFTP plugin, we’ll use 5 requests per second as a conservative default.

Why rate limiting matters

formae runs multiple operations concurrently:
  • User-triggered applies and destroys
  • Background synchronization (periodic reads)
  • Discovery scans
Without rate limiting, these could overwhelm your target system. The rate limiter ensures all operations share a fair quota.

LabelConfig

When formae discovers resources, it needs a human-readable label to display. The LabelConfig() method tells formae how to extract labels from your resources.

Configuration fields

JSONPath for labels

The DefaultQuery is a JSONPath expression that extracts a label from the resource’s JSON representation. For our File resource:
Using $.path extracts /data/config.txt as the label.

Resource overrides

If your plugin has multiple resource types with different naming conventions, use ResourceOverrides:
For our simple SFTP plugin with only one resource type, we don’t need overrides.

DiscoveryFilters (optional)

The DiscoveryFilters() method excludes certain resources from discovery. For now, we return nil to discover all files:
This is covered in detail in Discovery filters.

Update sftp.go

The template already has these methods. Update RateLimit() and LabelConfig() with our values:

Verify

To verify that the configuration methods compile correctly:

Summary

With configuration methods complete, your plugin now tells formae:
  1. Rate limit: 5 requests per second to protect the SFTP server
  2. Labels: Use the file path as the display name for discovered files
  3. Discovery filters: Discover all files (no exclusions)

Next: 05 - Create