maas 0.0.10
maas: ^0.0.10 copied to clipboard
maas is an MPC network solution to serve resource as service.
Mesh: A lightweight, distributed, relational network architecture for MPC #
Introduction #
Mesh is a MPC network solution to serve resource as service.
Also is A replacement for RPC Framework like dubbo, IOC Container like spring, Serialize Library like json_serializable.
Use easy and sample design to provide strong, robust, and type safe encoding experience.
Features #
As an open source network proxy, Mesh has the following core functions:
- Support full dynamic resource configuration through xDS API integrated with Service Mesh.
- Support proxy with TCP, HTTP, and RPC protocols.
- Support rich routing features.
- Support reliable upstream management and load balancing capabilities.
- Support network and protocol layer observability.
- Support mTLS and protocols on TLS.
- Support rich extension mechanism to provide highly customizable expansion capabilities.
- Support process smooth upgrade.
Get Started #
Install go compile time.
flutter pub get mesh
Documentation #
Add dependencies.
dart pub add maas
dart pub add dev:build_runner
dart pub add dev:source_gen
Use with build_runner. Add below to your build.yaml file.
# Read about `build.yaml` at https://pub.dev/packages/build_config
builders:
mesh:
import: "package:maas/dyn/dyn.dart"
builder_factories: [ "dyn" ]
build_extensions: { ".dart": [ "mesh.g.dart" ] }
auto_apply: dependents
build_to: cache
applies_builders: [ "source_gen|combining_builder" ]
targets:
$default:
builders:
mesh:
enabled: true
options:
debug: true
log_level: fine
source_gen|combining_builder:
enabled: true
options:
debug: true
log_level: fine
Generate code by mesh dyn builder.
dart run build_runner build
Remote call and JSON codec example with mesh.
import 'package:maas/index.dart';
import 'package:maas/gen/index.g.dart';
@SPI(name: "foo")
abstract class IFoo {
Future<String?> doc(String name, String formatter, {Context? ctx});
}
@SPI(name: "foo")
class Foo implements IFoo {
@SPI(name: 'mpi')
late Builtin builtin;
@override
Future<String?> doc(String name, String formatter, {Context? ctx}) async {
return await builtin.doc(name, formatter, ctx: ctx);
}
}
Future<void> main() async {
maas();
final vars = Proxy.spi<Vars>();
vars.setenv('MESH_ADDRESS', 'https://127.0.0.1:443');
final builtin = Proxy.mpi<Builtin>();
final doc = await builtin.doc('', '');
info('$doc');
final foo = Proxy.spi<IFoo>();
final docx = await foo.doc('', '');
info('$docx');
final codec = Proxy.spi<Codec>();
final json = codec.encodeString(Body(codec: 'x', schema: 'y'));
info(json);
final body = codec.decodeString<Body>(json);
info(body.codec ?? '');
}