Initial commit

This commit is contained in:
2026-02-23 13:02:22 +03:00
commit 42d2900df9
108 changed files with 4491 additions and 0 deletions

View File

@@ -0,0 +1,37 @@
import 'package:grpc/grpc.dart';
import '../gen/notes/v1/notes.pbgrpc.dart';
/// Singleton gRPC клиент.
/// Подключается к Go бекенду на localhost:50051.
class GrpcClient {
static GrpcClient? _instance;
late final ClientChannel _channel;
late final NoteServiceClient noteService;
GrpcClient._() {
_channel = ClientChannel(
'localhost',
port: 50051,
options: const ChannelOptions(
credentials: ChannelCredentials.insecure(),
),
);
// noteService — типизированный клиент.
// Все методы (createNote, listNotes и т.д.)
// сгенерированы из proto и принимают/возвращают
// типизированные объекты. Невозможно передать
// неверный тип — ошибка компиляции Dart.
noteService = NoteServiceClient(_channel);
}
static GrpcClient get instance {
_instance ??= GrpcClient._();
return _instance!;
}
Future<void> shutdown() async {
await _channel.shutdown();
}
}