Fennec은 고성능 백엔드 서비스를 구축하기 위해 설계된 다중 스레드 및 견고한 Dart 서버 사이드 프레임워크입니다. 개발자들이 Dart를 사용하여 확장 가능한 웹 서버와 API를 만들 수 있도록 하며, 병렬 처리를 활용해 여러 요청을 효율적으로 처리할 수 있습니다. 신뢰성과 속도를 중시하여 개발되었으며, Android, iOS, macOS, Windows, Linux에서 배포가 가능해 크로스플랫폼 백엔드 솔루션에 적합합니다. 단순성과 개발 생산성을 강조하면서도 강력한 성능 특성을 유지합니다.
사용 사례
RESTful API 구축
실시간 백엔드 서비스 만들기
크로스 플랫폼 서버 애플리케이션 개발
고병렬 작업 부하 처리
Flutter 프론트엔드 앱과의 통합
주요 기능
다중 스레드 아키텍처
크로스 플랫폼 지원
고성능 및 확장성
내장된 동시성 모델
간단한 API 설계
강력한 오류 처리
적합한 대상
Dart를 사용하는 백엔드 개발자
풀스택 플러터 앱을 개발하는 팀
고처리량이 필요한 프로젝트
경량 서버 프레임워크를 찾는 개발자
크로스 플랫폼 배포가 필요한 응용 프로그램
고려 사항
Dart 동시성에 대한 이해 필요
성숙한 프레임워크에 비해 생태계가 제한적
현대적인 Dart 프로젝트에 가장 적합
생산 배포를 위해 추가 도구가 필요할 수 있습니다
서버 측 Dart에 익숙하지 않은 초보자를 위한 학습 곡선
원본 README
연결된 소스 저장소의 README 원문 스냅샷입니다. 최신 내용은 저장소에서 확인하세요.
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.