RustRemoteSettings.sys.mjs¶
- class RustRemoteSettings.sys.RemoteSettingsClient()¶
Client for a single Remote Settings collection
Use [RemoteSettingsService::make_client] to create these.
- RustRemoteSettings.sys.RemoteSettingsClient.collectionName()¶
Collection this client is for
- Returns:
string –
- RustRemoteSettings.sys.RemoteSettingsClient.getAttachment(attachmentId)¶
Get attachment data for a remote settings record
Attachments are large binary blobs used for data that doesn’t fit in a normal record. They are handled differently than other record data:
Attachments are not downloaded in [RemoteSettingsService::sync]
This method will make network requests if the attachment is not cached
This method will throw if there is a network or other error when fetching the
attachment data.
- Returns:
string –
- RustRemoteSettings.sys.RemoteSettingsClient.getRecords(syncIfEmpty)¶
Get the current set of records.
This method normally fetches records from the last sync. This means that it returns fast and does not make any network requests.
If records have not yet been synced it will return None. Use sync_if_empty = true to change this behavior and perform a network request in this case. That this is probably a bad idea if you want to fetch the setting in application startup or when building the UI.
None will also be returned on disk IO errors or other unexpected errors. The reason for this is that there is not much an application can do in this situation other than fall back to the same default handling as if records have not been synced.
TODO(Bug 1919141):
Application-services schedules regular dumps of the server data for specific collections. For these collections, get_records will never return None. If you would like to add your collection to this list, please reach out to the DISCO team.
- Returns:
Array.<RemoteSettingsRecord> –
- RustRemoteSettings.sys.RemoteSettingsClient.getRecordsMap(syncIfEmpty)¶
Get the current set of records as a map of record_id -> record.
See [Self::get_records] for an explanation of when this makes network requests, error handling, and how the sync_if_empty param works.
- Returns:
object –
- class RustRemoteSettings.sys.RemoteSettingsService()¶
Application-level Remote Settings manager.
This handles application-level operations, like syncing all the collections, and acts as a factory for creating clients.
- RustRemoteSettings.sys.RemoteSettingsService.makeClient(collectionName)¶
Create a new Remote Settings client
- Returns:
RemoteSettingsClient –
- RustRemoteSettings.sys.RemoteSettingsService.sync()¶
Sync collections for all active clients
- Returns:
Array.<string> –
- RustRemoteSettings.sys.RemoteSettingsService.updateConfig(config)¶
Update the remote settings config
This will cause all current and future clients to use new config and will delete any stored records causing the clients to return new results from the new config.
Only intended for QA/debugging. Swapping the remote settings server in the middle of execution can cause weird effects.
- static RustRemoteSettings.sys.RemoteSettingsService.init(storageDir, config)¶
Construct a [RemoteSettingsService]
This is typically done early in the application-startup process
- Returns:
RemoteSettingsService –
- class RustRemoteSettings.sys.Attachment()¶
Attachment metadata that can be optionally attached to a [Record]. The [location] should included in calls to [Client::get_attachment].
- RustRemoteSettings.sys.Attachment.filename¶
type: string
- RustRemoteSettings.sys.Attachment.hash¶
type: string
- RustRemoteSettings.sys.Attachment.location¶
type: string
- RustRemoteSettings.sys.Attachment.mimetype¶
type: string
- RustRemoteSettings.sys.Attachment.size¶
type: number
- class RustRemoteSettings.sys.RemoteSettingsConfig()¶
Custom configuration for the client. Currently includes the following: - server: The Remote Settings server to use. If not specified, defaults to the production server (RemoteSettingsServer::Prod). - server_url: An optional custom Remote Settings server URL. Deprecated; please use server instead. - bucket_name: The optional name of the bucket containing the collection on the server. If not specified, the standard bucket will be used. - collection_name: The name of the collection for the settings server.
- RustRemoteSettings.sys.RemoteSettingsConfig.bucketName¶
type: string
- RustRemoteSettings.sys.RemoteSettingsConfig.collectionName¶
type: string
- RustRemoteSettings.sys.RemoteSettingsConfig.server¶
type: RemoteSettingsServer
- RustRemoteSettings.sys.RemoteSettingsConfig.serverUrl¶
type: string
- class RustRemoteSettings.sys.RemoteSettingsConfig2()¶
Remote settings configuration
This is the version used in the new API, hence the 2 at the end. The plan is to move consumers to the new API, remove the RemoteSettingsConfig struct, then remove the 2 from this name.
- RustRemoteSettings.sys.RemoteSettingsConfig2.bucketName¶
type: string
Bucket name to use, defaults to “main”. Use “main-preview” for a preview bucket
- RustRemoteSettings.sys.RemoteSettingsConfig2.server¶
type: RemoteSettingsServer
The Remote Settings server to use. Defaults to [RemoteSettingsServer::Prod],
- class RustRemoteSettings.sys.RemoteSettingsRecord()¶
A parsed Remote Settings record. Records can contain arbitrary fields, so clients are required to further extract expected values from the [fields] member.
- RustRemoteSettings.sys.RemoteSettingsRecord.attachment¶
type: Attachment
- RustRemoteSettings.sys.RemoteSettingsRecord.deleted¶
type: Boolean
- RustRemoteSettings.sys.RemoteSettingsRecord.fields¶
type: RsJsonObject
- RustRemoteSettings.sys.RemoteSettingsRecord.id¶
type: string
- RustRemoteSettings.sys.RemoteSettingsRecord.lastModified¶
type: number
- class RustRemoteSettings.sys.RemoteSettingsResponse()¶
Data structure representing the top-level response from the Remote Settings. [last_modified] will be extracted from the etag header of the response.
- RustRemoteSettings.sys.RemoteSettingsResponse.lastModified¶
type: number
- RustRemoteSettings.sys.RemoteSettingsResponse.records¶
type: Array.<RemoteSettingsRecord>
- class RustRemoteSettings.sys.RemoteSettingsError()¶
Public error class, this is what we return to consumers
- class RustRemoteSettings.sys.RemoteSettingsServer()¶
The Remote Settings server that the client should use.
- RustRemoteSettings.sys.RemoteSettingsServer.Custom¶
- RustRemoteSettings.sys.RemoteSettingsServer.Dev¶
- RustRemoteSettings.sys.RemoteSettingsServer.Prod¶
- RustRemoteSettings.sys.RemoteSettingsServer.Stage¶
- class RustRemoteSettings.sys.Network()¶
Network error while making a remote settings request
- class RustRemoteSettings.sys.Backoff()¶
The server has asked the client to backoff.
- class RustRemoteSettings.sys.Other()¶
Other