Aus öffentlichen Paketdaten erstellte Orientierung.
Fennec ist ein mehrthreadiger, robuster Dart-Server-Framework, der für die Erstellung leistungsstarker Backend-Dienste konzipiert wurde. Es ermöglicht Entwicklern, skalierbare Webserver und APIs mit Dart zu erstellen, wobei die Konkurrenz effizient zur Bewältigung mehrerer Anfragen genutzt wird. Mit Fokus auf Zuverlässigkeit und Geschwindigkeit unterstützt Fennec die Bereitstellung auf Android, iOS, macOS, Windows und Linux und ist somit ideal für plattformübergreifende Backend-Lösungen. Seine Architektur betont Einfachheit und Entwicklerproduktivität, während starke Leistungsmerkmale erhalten bleiben.
Anwendungsfälle
RESTful APIs erstellen
Erstellen von Echtzeit-Backend-Diensten
Entwicklung von plattformübergreifenden Serveranwendungen
Behandlung von Hochlastarbeitslasten
Integration mit Flutter-Frontend-Anwendungen
Hauptmerkmale
Mehrdraht-Architektur
Plattformübergreifende Unterstützung
Hohe Leistung und Skalierbarkeit
eingebautes Konkurrenzmodell
Einfaches API-Design
Robuste Fehlerbehandlung
Geeignet für
Backend-Entwickler, die Dart verwenden
Teams, die vollständige Flutter-Anwendungen erstellen
Projekte mit hohem Durchsatzbedarf
Entwickler, die leichte Server-Frameworks suchen
Anwendungen, die eine plattformübergreifende Bereitstellung erfordern
Hinweise
Erfahrung mit Dart-Konkurrenz erforderlich
Beschränktes Ökosystem im Vergleich zu etablierten Frameworks
Am besten geeignet für moderne Dart-Projekte
Möglicherweise sind zusätzliche Werkzeuge für die Produktionsbereitstellung erforderlich
Lernkurve für Anfänger, die mit Server-seitigem Dart nicht vertraut sind
Original-README
Originaler README-Schnappschuss aus dem verknüpften Quell-Repository. Aktuelle Inhalte finden Sie im Repository.
Fennec is a multi-threaded, robust Dart Server-Side Framework.
Sharing Data between Isolates if using multiples Isolates.
Isolate is an isolated environment, inside which there is memory allocated to it and its EventLoop. but sometimes you want to share Data between Isolates or have the same Data content on all Isolates.
Fennec let you do that by using Actor Concept.
first you need to create your Actor customized class that is a subclass of Actor.
example how to implement it.
classCustomisedActorextendsActor{
finalList<String> _strings = [];
CustomisedActor(String name) : super(name);
@overrideFutureOr<void> execute(String action,
{Map<String, dynamic> data = const {}}) {
if (action == 'insert') {
_strings.add(" new item");
} else {
if (_strings.isNotEmpty) {
_strings.removeLast();
}
}
}
@overrideFutureOrget(String action, {Map<String, dynamic> data = const {}}) {
if (action == "get") {
return _strings;
}
returnnull;
}
}
after implementing of your needed subclasses of [Actor], you need just to add it/them to your [Application] by using addActor or addActors in [Application] instance.
with [ServerContext] instance you can have access to your Actor/Actors by their name and you can call get and execute methods to return some Data from Actor or execute some operations.
you can render also html templates with fennec Framework. you need to determine the path for your
html files. application.setViewPath(path.current + '/example');
WebSocket is already integrated in the core of Framework. firstly to use Websocket . you need to
make the useWebSocket object at [Application] instance true.
Fennec Framework supports also Multithreading over isolates. To increase the number of used isolates
just call the function setNumberOfIsolates. the default number of isolates is 1
example
application.setNumberOfIsolates(1
);
Start your Server and test your first Request
import'package:fennec/fennec.dart';
voidmain(List<String> arguments) async {
Application application = Application();
application.setNumberOfIsolates(1);
application.useWebSocket(true);
application.setPort(8000);
application.addRouters([testRouter()]);
ServerInfo serverInfo = await application.runServer();
print("Server is running at Port ${serverInfo.port}");
}}
deploy
heroku cloud:here is heroku-buildpack
for dart and inside it an example how to deploy Fennec Framework on heroku cloud for free. to test
an example you can try this two endpoints:
Running 1m test @ http://localhost:8000/example/test
10 threads and 100 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 6.50ms 1.27ms 104.08ms 96.71%
Req/Sec 1.55k 124.24 2.41k 87.15%
926903 requests in 1.00m, 180.33MB read
Requests/sec: 15435.91
Transfer/sec: 3.00MB
import information
Fennec Framework after with version >= 1.0.0 doesn't support more annotations because the big
discussions about the library mirrors. as alernatives you can use Route or Route as showed in this
example.