at_persistence_secondary_server 5.0.0 copy "at_persistence_secondary_server: ^5.0.0" to clipboard
at_persistence_secondary_server: ^5.0.0 copied to clipboard

A Dart library with the implementation classes for the persistence layer of the secondary server.

example/main.dart

import 'dart:io';

import 'package:at_persistence_secondary_server/at_persistence_secondary_server.dart';
import 'package:at_persistence_secondary_server/hive.dart';

Future<void> main(List<String> arguments) async {
  final storageDir = '${Directory.current.path}/example/hive';
  final factory = HiveAtPersistenceFactory();

  // Bring up persistence for @alice with all server-side capabilities
  // (keystore + commit log + access log + notification keystore).
  final bundle = await factory.initialize(
    '@alice',
    HivePersistenceConfig.serverDefaults(
      storagePath: '$storageDir/keys',
      commitLogPath: '$storageDir/commitLog',
      accessLogPath: '$storageDir/accessLog',
      notificationStoragePath: '$storageDir/notifications',
    ),
  );

  // Keystore
  final atData = AtData()..data = '123';
  final result = await bundle.keyValueStore.create('phone@alice', atData);
  print(result);

  // Commit log lives inside the keystore.
  final hiveKey = await bundle.keyValueStore.commitLog!
      .commit('location@alice', CommitOp.UPDATE);
  print(hiveKey);

  // Notification keystore
  final atNotification = (AtNotificationBuilder()
        ..id = '123'
        ..fromAtSign = '@alice'
        ..notificationDateTime = DateTime.now().toUtcMillisecondsPrecision()
        ..toAtSign = '@alice'
        ..notification = 'self_received_notification'
        ..type = NotificationType.received
        ..opType = OperationType.update)
      .build();
  await bundle.notificationKeystore!.put('@alice', atNotification);
  final notificationEntry = await bundle.notificationKeystore!.get('@alice');
  print(notificationEntry);

  await factory.close();
}
5
likes
140
points
13.1k
downloads

Documentation

API reference

Publisher

verified publisheratsign.org

Weekly Downloads

A Dart library with the implementation classes for the persistence layer of the secondary server.

Homepage
Repository (GitHub)
View/report issues
Contributing

License

BSD-3-Clause (license)

Dependencies

at_commons, at_utf7, at_utils, cron, crypto, hive, meta, path, uuid

More

Packages that depend on at_persistence_secondary_server