refactor(updater): remove client_id (#78)
This commit is contained in:
@@ -10,8 +10,6 @@ import 'package:ffi/ffi.dart';
|
||||
class AppParameters extends ffi.Struct {
|
||||
external ffi.Pointer<Utf8> channel;
|
||||
// ignore: non_constant_identifier_names
|
||||
external ffi.Pointer<Utf8> client_id;
|
||||
// ignore: non_constant_identifier_names
|
||||
external ffi.Pointer<Utf8> app_id;
|
||||
// ignore: non_constant_identifier_names
|
||||
external ffi.Pointer<Utf8> base_version;
|
||||
@@ -24,17 +22,16 @@ class AppParameters extends ffi.Struct {
|
||||
// ignore: non_constant_identifier_names
|
||||
external ffi.Pointer<Utf8> cache_dir;
|
||||
|
||||
static ffi.Pointer<AppParameters> allocate(
|
||||
{required String clientId,
|
||||
required String appId,
|
||||
required String version,
|
||||
required String channel,
|
||||
required String? updateUrl,
|
||||
required String libappPath,
|
||||
required String libflutterPath,
|
||||
required String cacheDir}) {
|
||||
static ffi.Pointer<AppParameters> allocate({
|
||||
required String appId,
|
||||
required String version,
|
||||
required String channel,
|
||||
required String? updateUrl,
|
||||
required String libappPath,
|
||||
required String libflutterPath,
|
||||
required String cacheDir,
|
||||
}) {
|
||||
var config = calloc<AppParameters>();
|
||||
config.ref.client_id = clientId.toNativeUtf8();
|
||||
config.ref.app_id = appId.toNativeUtf8();
|
||||
config.ref.base_version = version.toNativeUtf8();
|
||||
config.ref.channel = channel.toNativeUtf8();
|
||||
@@ -48,7 +45,6 @@ class AppParameters extends ffi.Struct {
|
||||
}
|
||||
|
||||
static void free(ffi.Pointer<AppParameters> config) {
|
||||
calloc.free(config.ref.client_id);
|
||||
calloc.free(config.ref.app_id);
|
||||
calloc.free(config.ref.base_version);
|
||||
calloc.free(config.ref.channel);
|
||||
|
||||
@@ -49,8 +49,7 @@ class Updater {
|
||||
// This is only used when called from a Dart command line.
|
||||
// Shorebird will have initialized the library already for you when
|
||||
// inside a Flutter app.
|
||||
static void initUpdaterLibrary({
|
||||
required String clientId,
|
||||
static void initUpdaterLibrary({
|
||||
required String appId,
|
||||
required String version,
|
||||
required String channel,
|
||||
@@ -65,8 +64,7 @@ class Updater {
|
||||
channel: channel,
|
||||
updateUrl: updateUrl,
|
||||
libappPath: baseLibraryPath,
|
||||
libflutterPath: vmPath,
|
||||
clientId: clientId,
|
||||
libflutterPath: vmPath,
|
||||
cacheDir: cacheDir,
|
||||
);
|
||||
try {
|
||||
|
||||
@@ -10,7 +10,6 @@ void main(List<String> args) async {
|
||||
Updater.loadLibrary(directory: directory, name: "updater");
|
||||
|
||||
Updater.initUpdaterLibrary(
|
||||
clientId: 'my-client-id',
|
||||
appId: 'demo',
|
||||
version: '1.0.0',
|
||||
channel: 'stable',
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
use std::fs::File;
|
||||
use std::io::{BufReader, BufWriter};
|
||||
use std::path::Path;
|
||||
use uuid::Uuid;
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
@@ -26,13 +25,6 @@ struct Slot {
|
||||
// anything inside should be done via the functions below.
|
||||
#[derive(Deserialize, Serialize)]
|
||||
pub struct UpdaterState {
|
||||
// The purpose of the client_id is to allow for staged rollouts
|
||||
// the server needs some sort of per-client number, so that it can bucket
|
||||
// and say "this client is in the 10% bucket, so it gets the new version".
|
||||
// It might be better for this to just be a number 0-100?
|
||||
#[serde(default = "Uuid::new_v4")]
|
||||
/// ID generated for this device/client used for staged rollouts.
|
||||
client_id: Uuid,
|
||||
/// List of patches that failed to boot. We will never attempt these again.
|
||||
failed_patches: Vec<String>,
|
||||
/// List of patches that successfully booted. We will never rollback past
|
||||
@@ -48,7 +40,6 @@ pub struct UpdaterState {
|
||||
impl Default for UpdaterState {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
client_id: Uuid::new_v4(),
|
||||
current_slot_index: 0,
|
||||
failed_patches: Vec::new(),
|
||||
successful_patches: Vec::new(),
|
||||
@@ -111,10 +102,6 @@ impl UpdaterState {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn client_id(&self) -> String {
|
||||
self.client_id.to_string()
|
||||
}
|
||||
|
||||
pub fn current_patch(&self) -> Option<PatchInfo> {
|
||||
// If there is no state, return None.
|
||||
if self.slots.is_empty() {
|
||||
|
||||
@@ -38,7 +38,6 @@ pub fn send_patch_check_request(
|
||||
// Send the request to the server.
|
||||
let client = reqwest::blocking::Client::new();
|
||||
let mut body = HashMap::new();
|
||||
body.insert("client_id", state.client_id());
|
||||
body.insert("app_id", config.app_id.clone());
|
||||
body.insert("channel", config.channel.clone());
|
||||
body.insert("base_version", config.base_version.clone());
|
||||
|
||||
Reference in New Issue
Block a user