Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -770,7 +770,7 @@ open class NimbusClient: NimbusClientProtocol, @unchecked Sendable {
public func uniffiCloneHandle() -> UInt64 {
return try! rustCall { uniffi_nimbus_fn_clone_nimbusclient(self.handle, $0) }
}
public convenience init(appCtx: AppContext, recordedContext: RecordedContext?, coenrollingFeatureIds: [String], dbpath: String, metricsHandler: MetricsHandler, geckoPrefHandler: GeckoPrefHandler?, remoteSettingsService: RemoteSettingsService?, collectionName: String?)throws {
public convenience init(appCtx: AppContext, recordedContext: RecordedContext?, coenrollingFeatureIds: [String], dbpath: String, metricsHandler: MetricsHandler, geckoPrefHandler: GeckoPrefHandler?, remoteSettingsInfo: NimbusServerSettings?)throws {
let handle =
try rustCallWithError(FfiConverterTypeNimbusError_lift) {
uniffi_nimbus_fn_constructor_nimbusclient_new(
Expand All @@ -780,8 +780,7 @@ public convenience init(appCtx: AppContext, recordedContext: RecordedContext?, c
FfiConverterString.lower(dbpath),
FfiConverterCallbackInterfaceMetricsHandler_lower(metricsHandler),
FfiConverterOptionCallbackInterfaceGeckoPrefHandler.lower(geckoPrefHandler),
FfiConverterOptionTypeRemoteSettingsService.lower(remoteSettingsService),
FfiConverterOptionString.lower(collectionName),$0
FfiConverterOptionTypeNimbusServerSettings.lower(remoteSettingsInfo),$0
)
}
self.init(unsafeFromHandle: handle)
Expand Down Expand Up @@ -2532,6 +2531,60 @@ public func FfiConverterTypeMalformedFeatureConfigExtraDef_lower(_ value: Malfor
}


public struct NimbusServerSettings {
public var rsService: RemoteSettingsService
public var collectionName: String

// Default memberwise initializers are never public by default, so we
// declare one manually.
public init(rsService: RemoteSettingsService, collectionName: String) {
self.rsService = rsService
self.collectionName = collectionName
}




}

#if compiler(>=6)
extension NimbusServerSettings: Sendable {}
#endif

#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public struct FfiConverterTypeNimbusServerSettings: FfiConverterRustBuffer {
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> NimbusServerSettings {
return
try NimbusServerSettings(
rsService: FfiConverterTypeRemoteSettingsService.read(from: &buf),
collectionName: FfiConverterString.read(from: &buf)
)
}

public static func write(_ value: NimbusServerSettings, into buf: inout [UInt8]) {
FfiConverterTypeRemoteSettingsService.write(value.rsService, into: &buf)
FfiConverterString.write(value.collectionName, into: &buf)
}
}


#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeNimbusServerSettings_lift(_ buf: RustBuffer) throws -> NimbusServerSettings {
return try FfiConverterTypeNimbusServerSettings.lift(buf)
}

#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeNimbusServerSettings_lower(_ value: NimbusServerSettings) -> RustBuffer {
return FfiConverterTypeNimbusServerSettings.lower(value)
}


public struct OriginalGeckoPref: Equatable, Hashable {
public var pref: String
public var branch: PrefBranch
Expand Down Expand Up @@ -3684,22 +3737,22 @@ fileprivate struct FfiConverterOptionTypeRecordedContext: FfiConverterRustBuffer
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
fileprivate struct FfiConverterOptionTypeRemoteSettingsService: FfiConverterRustBuffer {
typealias SwiftType = RemoteSettingsService?
fileprivate struct FfiConverterOptionTypeNimbusServerSettings: FfiConverterRustBuffer {
typealias SwiftType = NimbusServerSettings?

public static func write(_ value: SwiftType, into buf: inout [UInt8]) {
guard let value = value else {
writeInt(&buf, Int8(0))
return
}
writeInt(&buf, Int8(1))
FfiConverterTypeRemoteSettingsService.write(value, into: &buf)
FfiConverterTypeNimbusServerSettings.write(value, into: &buf)
}

public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SwiftType {
switch try readInt(&buf) as Int8 {
case 0: return nil
case 1: return try FfiConverterTypeRemoteSettingsService.read(from: &buf)
case 1: return try FfiConverterTypeNimbusServerSettings.read(from: &buf)
default: throw UniffiInternalError.unexpectedOptionalTag
}
}
Expand Down Expand Up @@ -4403,7 +4456,7 @@ private let initializationResult: InitializationResult = {
if (uniffi_nimbus_checksum_method_recordedcontext_to_json() != 52035) {
return InitializationResult.apiChecksumMismatch
}
if (uniffi_nimbus_checksum_constructor_nimbusclient_new() != 28763) {
if (uniffi_nimbus_checksum_constructor_nimbusclient_new() != 32755) {
return InitializationResult.apiChecksumMismatch
}
if (uniffi_nimbus_checksum_method_geckoprefhandler_get_prefs_with_state() != 27063) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,18 +234,6 @@ public extension Notification.Name {
static let nimbusExperimentsApplied = Notification.Name("nimbusExperimentsApplied")
}

/// This struct is used during in the `create` method to point `Nimbus` at the given `RemoteSettings` server.
///
public struct NimbusServerSettings {
public init(url: URL, collection: String = remoteSettingsCollection) {
self.url = url
self.collection = collection
}

public let url: URL
public let collection: String
}

public let remoteSettingsCollection = "nimbus-mobile-experiments"
public let remoteSettingsPreviewCollection = "nimbus-preview"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,23 +191,11 @@ public class NimbusBuilder {
appInfo: NimbusAppSettings,
remoteSettingsService: RemoteSettingsService? = nil
) -> NimbusInterface {
let serverSettings: NimbusServerSettings?
if let string = url,
let url = URL(string: string)
{
if usePreviewCollection {
serverSettings = NimbusServerSettings(url: url, collection: remoteSettingsPreviewCollection)
} else {
serverSettings = NimbusServerSettings(url: url, collection: remoteSettingsCollection)
}
} else {
serverSettings = nil
}

do {
let nimbus = try newNimbus(
appInfo,
serverSettings: serverSettings,
serverSettings: nil,
remoteSettingsService: remoteSettingsService
)
let fm = featureManifest
Expand All @@ -234,7 +222,7 @@ public class NimbusBuilder {
// Is the app being built locally, and the nimbus-cli
// hasn't been used before this run.
func isLocalBuild() -> Bool {
serverSettings == nil && nimbus.isFetchEnabled()
nimbus.isFetchEnabled()
}

if let args = ArgumentProcessor.createCommandLineArgs(args: commandLineArgs) {
Expand Down Expand Up @@ -271,16 +259,14 @@ public class NimbusBuilder {
serverSettings: NimbusServerSettings?,
remoteSettingsService: RemoteSettingsService?
) throws -> NimbusInterface {
try Nimbus.create(serverSettings,
try Nimbus.create(server: serverSettings,
appSettings: appInfo,
coenrollingFeatureIds: getCoenrollingFeatureIds(),
dbPath: dbFilePath,
resourceBundles: resourceBundles,
userDefaults: userDefaults,
errorReporter: errorReporter,
recordedContext: recordedContext,
remoteSettingsService: remoteSettingsService,
collectionName: serverSettings?.collection)
recordedContext: recordedContext)
}

func newNimbusDisabled() -> NimbusInterface {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public extension Nimbus {
/// - Throws `NimbusError` if anything goes wrong with the Rust FFI or in the `NimbusClient` constructor.
///
static func create(
_ server: NimbusServerSettings?,
server: NimbusServerSettings?,
appSettings: NimbusAppSettings,
coenrollingFeatureIds: [String] = [],
dbPath: String,
Expand All @@ -94,21 +94,15 @@ public extension Nimbus {
}

let context = Nimbus.buildExperimentContext(appSettings)
let remoteSettings = server.map { server -> RemoteSettingsConfig in
RemoteSettingsConfig(
collectionName: server.collection,
server: .custom(url: server.url.absoluteString)
)
}

let nimbusClient = try NimbusClient(
appCtx: context,
recordedContext: recordedContext,
coenrollingFeatureIds: coenrollingFeatureIds,
dbpath: dbPath,
metricsHandler: GleanMetricsHandler(),
geckoPrefHandler: nil,
remoteSettingsService: remoteSettingsService,
collectionName: collectionName
remoteSettingsInfo: server,
)

return Nimbus(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -770,7 +770,7 @@ open class NimbusClient: NimbusClientProtocol, @unchecked Sendable {
public func uniffiCloneHandle() -> UInt64 {
return try! rustCall { uniffi_nimbus_fn_clone_nimbusclient(self.handle, $0) }
}
public convenience init(appCtx: AppContext, recordedContext: RecordedContext?, coenrollingFeatureIds: [String], dbpath: String, metricsHandler: MetricsHandler, geckoPrefHandler: GeckoPrefHandler?, remoteSettingsService: RemoteSettingsService?, collectionName: String?)throws {
public convenience init(appCtx: AppContext, recordedContext: RecordedContext?, coenrollingFeatureIds: [String], dbpath: String, metricsHandler: MetricsHandler, geckoPrefHandler: GeckoPrefHandler?, remoteSettingsInfo: NimbusServerSettings?)throws {
let handle =
try rustCallWithError(FfiConverterTypeNimbusError_lift) {
uniffi_nimbus_fn_constructor_nimbusclient_new(
Expand All @@ -780,8 +780,7 @@ public convenience init(appCtx: AppContext, recordedContext: RecordedContext?, c
FfiConverterString.lower(dbpath),
FfiConverterCallbackInterfaceMetricsHandler_lower(metricsHandler),
FfiConverterOptionCallbackInterfaceGeckoPrefHandler.lower(geckoPrefHandler),
FfiConverterOptionTypeRemoteSettingsService.lower(remoteSettingsService),
FfiConverterOptionString.lower(collectionName),$0
FfiConverterOptionTypeNimbusServerSettings.lower(remoteSettingsInfo),$0
)
}
self.init(unsafeFromHandle: handle)
Expand Down Expand Up @@ -2532,6 +2531,60 @@ public func FfiConverterTypeMalformedFeatureConfigExtraDef_lower(_ value: Malfor
}


public struct NimbusServerSettings {
public var rsService: RemoteSettingsService
public var collectionName: String

// Default memberwise initializers are never public by default, so we
// declare one manually.
public init(rsService: RemoteSettingsService, collectionName: String) {
self.rsService = rsService
self.collectionName = collectionName
}




}

#if compiler(>=6)
extension NimbusServerSettings: Sendable {}
#endif

#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public struct FfiConverterTypeNimbusServerSettings: FfiConverterRustBuffer {
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> NimbusServerSettings {
return
try NimbusServerSettings(
rsService: FfiConverterTypeRemoteSettingsService.read(from: &buf),
collectionName: FfiConverterString.read(from: &buf)
)
}

public static func write(_ value: NimbusServerSettings, into buf: inout [UInt8]) {
FfiConverterTypeRemoteSettingsService.write(value.rsService, into: &buf)
FfiConverterString.write(value.collectionName, into: &buf)
}
}


#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeNimbusServerSettings_lift(_ buf: RustBuffer) throws -> NimbusServerSettings {
return try FfiConverterTypeNimbusServerSettings.lift(buf)
}

#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeNimbusServerSettings_lower(_ value: NimbusServerSettings) -> RustBuffer {
return FfiConverterTypeNimbusServerSettings.lower(value)
}


public struct OriginalGeckoPref: Equatable, Hashable {
public var pref: String
public var branch: PrefBranch
Expand Down Expand Up @@ -3684,22 +3737,22 @@ fileprivate struct FfiConverterOptionTypeRecordedContext: FfiConverterRustBuffer
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
fileprivate struct FfiConverterOptionTypeRemoteSettingsService: FfiConverterRustBuffer {
typealias SwiftType = RemoteSettingsService?
fileprivate struct FfiConverterOptionTypeNimbusServerSettings: FfiConverterRustBuffer {
typealias SwiftType = NimbusServerSettings?

public static func write(_ value: SwiftType, into buf: inout [UInt8]) {
guard let value = value else {
writeInt(&buf, Int8(0))
return
}
writeInt(&buf, Int8(1))
FfiConverterTypeRemoteSettingsService.write(value, into: &buf)
FfiConverterTypeNimbusServerSettings.write(value, into: &buf)
}

public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SwiftType {
switch try readInt(&buf) as Int8 {
case 0: return nil
case 1: return try FfiConverterTypeRemoteSettingsService.read(from: &buf)
case 1: return try FfiConverterTypeNimbusServerSettings.read(from: &buf)
default: throw UniffiInternalError.unexpectedOptionalTag
}
}
Expand Down Expand Up @@ -4403,7 +4456,7 @@ private let initializationResult: InitializationResult = {
if (uniffi_nimbus_checksum_method_recordedcontext_to_json() != 52035) {
return InitializationResult.apiChecksumMismatch
}
if (uniffi_nimbus_checksum_constructor_nimbusclient_new() != 28763) {
if (uniffi_nimbus_checksum_constructor_nimbusclient_new() != 32755) {
return InitializationResult.apiChecksumMismatch
}
if (uniffi_nimbus_checksum_method_geckoprefhandler_get_prefs_with_state() != 27063) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -239,18 +239,6 @@ public extension Notification.Name {
static let nimbusExperimentsApplied = Notification.Name("nimbusExperimentsApplied")
}

/// This struct is used during in the `create` method to point `Nimbus` at the given `RemoteSettings` server.
///
public struct NimbusServerSettings {
public init(remoteSettingsService: RemoteSettingsService, collection: String = remoteSettingsCollection) {
self.remoteSettingsService = remoteSettingsService
self.collection = collection
}

public let remoteSettingsService: RemoteSettingsService
public let collection: String
}

public let remoteSettingsCollection = "nimbus-mobile-experiments"
public let remoteSettingsPreviewCollection = "nimbus-preview"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,9 +193,9 @@ public class NimbusBuilder {
) -> NimbusInterface {
let serverSettings: NimbusServerSettings?
if usePreviewCollection {
serverSettings = NimbusServerSettings(remoteSettingsService: remoteSettingsService, collection: remoteSettingsPreviewCollection)
serverSettings = NimbusServerSettings(rsService: remoteSettingsService, collectionName: remoteSettingsPreviewCollection)
} else {
serverSettings = NimbusServerSettings(remoteSettingsService: remoteSettingsService, collection: remoteSettingsCollection)
serverSettings = NimbusServerSettings(rsService: remoteSettingsService, collectionName: remoteSettingsCollection)
}

do {
Expand Down Expand Up @@ -260,7 +260,7 @@ public class NimbusBuilder {
_ appInfo: NimbusAppSettings,
serverSettings: NimbusServerSettings?
) throws -> NimbusInterface {
try Nimbus.create(serverSettings,
try Nimbus.create(server: serverSettings,
appSettings: appInfo,
coenrollingFeatureIds: getCoenrollingFeatureIds(),
dbPath: dbFilePath,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public extension Nimbus {
/// - Throws `NimbusError` if anything goes wrong with the Rust FFI or in the `NimbusClient` constructor.
///
static func create(
_ server: NimbusServerSettings?,
server: NimbusServerSettings?,
appSettings: NimbusAppSettings,
coenrollingFeatureIds: [String] = [],
dbPath: String,
Expand All @@ -99,8 +99,7 @@ public extension Nimbus {
dbpath: dbPath,
metricsHandler: GleanMetricsHandler(),
geckoPrefHandler: nil,
remoteSettingsService: server?.remoteSettingsService,
collectionName: server?.collection
remoteSettingsInfo: server,
)

return Nimbus(
Expand Down
Loading
Loading