Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[IMPL] - Custom backend server and improved configuration capabilities #4337

Closed

Conversation

KronosDev-Pro
Copy link

@KronosDev-Pro KronosDev-Pro commented Nov 8, 2024

Idea

Customize the backend server configuration as you like, and create a complete new backend server support.

can be easily split into another reflex package, for example pip install reflex[granian].

Example

We can define which BackendServer to use for development and production modes and thus customize the configuration (all parameters for each BackendServer are the actual parameters corresponding to the web server involved).

import reflex as rx
from reflex import server

config = rx.Config(
    app_name="examples",
    backend_server_dev = server.GunicornBackendServer(
        worker_class="uvicorn.workers.UvicornH11Worker",
        max_requests=100,
        max_requests_jitter=25,
        timeout=120,
        threads=1,
        workers=1,
    ),
    backend_server_prod = server.GranianBackendServer(
        threads=2,
        workers=4,
    )
)

We can also create a customized BackendServer with the CustomBackendServer class, such as GranianBackendServer


All Submissions:

  • Have you followed the guidelines stated in CONTRIBUTING.md file?
  • Have you checked to ensure there aren't any other open Pull Requests for the desired changed?

Type of change

  • New feature (non-breaking change which adds functionality)
  • This change requires a documentation update

New Feature Submission:

  • Does your submission pass the tests?
  • Have you linted your code locally prior to submission?

Changes To Core Features:

  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your core changes, as applicable?
  • Have you successfully ran tests with your changes locally?

@mmmcorpsvit
Copy link

hm... why not just use Pydantic Config package?

@KronosDev-Pro
Copy link
Author

hm... why not just use Pydantic Config package?

Basically, dataclasses is a native package that brings simplicity, performance and more customization possibilities. What's more, for this type of configuration, it doesn't need the validation and serialization/deserialization provided by pydantic.

KronosDev-Pro and others added 23 commits November 13, 2024 15:34
* require typing_extensions >= 4.6.0

TypeAliasType was added in 4.6

https://github.com/python/typing_extensions/blob/main/CHANGELOG.md#release-460-may-22-2023

* update lock file, even though nothing has changed
Co-authored-by: simon <simon@reflex.dev>
* make list suggestions work

* fix pyi
* bump some versions

* update ruff to 0.7.4

* bump tailwind version

* relock deps

---------

Co-authored-by: Masen Furer <m_github@0x26.net>
* fix: do not allow instantiation of State mixins
Closes reflex-dev#4343

* improve error message for ComponentState mixins

* fix typo

Co-authored-by: Masen Furer <m_github@0x26.net>

---------

Co-authored-by: Masen Furer <m_github@0x26.net>
* add typed dict type checking

* technically it has to be a mapping, not specifically a dict
* Add datetime to moment

* Remove recharts update

* Support other formats

* simplify

* Precommit

* PYI

* change imports for pyi compat

---------

Co-authored-by: Alek Petuskey <alekpetuskey@Aleks-MacBook-Pro.local>
Co-authored-by: Masen Furer <m_github@0x26.net>
* ignore rxconfig not in cwd

* no type ignore

* resolve paths

* Remove rxconfig module from sys.modules cache when reloading

* modify sys path

* add try except

* refactor inner function

---------

Co-authored-by: Masen Furer <m_github@0x26.net>
* fix appearance broken by reflex-dev#3812

* fix again to pass tests
)

The `rich` module should be set to `None`, indicating that rich should not be used.

Setting it to `False` worked before, but recently added code in typer fails
when checking `if rich is not None`.

ref: fastapi/typer#847
…v#4410)

In some cases, a routing failure can cause the failure to be cached. When the
router has a cached failure, pushing such a route will never call
routeChangeComplete, and thus on_load event will never be fired for that route.

Purposely clearing the error from the router allows the page to properly load
on subsequent attempts without refreshing the app.
Compiling pages in separate threads can result in `sys.path` being cleared,
which breaks subsequent imports.
* subtract 1 arg if the method is a bound method

* fix it early in user_args

* only bound methods pls

* add test
masenf and others added 12 commits January 6, 2025 14:35
Remove `packages` key, since this project uses the "default" package layout, so
this key isn't needed.
* Enable automatic retry on redis errors

ExponentialBackoff 3x retry for BusyLoadingError, ConnectionError, and TimeoutError

* retry on any redis error

* Use default single-retry for any RedisError

Using the default Retry means that async and sync clients get the appropriate type of Retry
* unbreak link _hover

* add a test to catch the error

* change tmp path for harness

* add () to fixture

* add spacer to avoid initial hover

* only install chromium browser for faster ci

---------

Co-authored-by: Lendemor <thomas.brandeho@gmail.com>
avoid lingering events after getting the information we came for
…v#4598)

Instead of potentially defining `_LANGUAGE` constant twice in a component,
simply pass the language prop directly to the hook generator function.

If no language is passed, then it defaults to `_LANGUAGE`, which continues to
work for markdown component_map use case.
* improve client state

* no comma

* update python for unit tests

* overwrite it for windows

* bump other python versions
* fix recursive UI

* get it right pyright

* dang it darglint
Use python versions that have a darwin/arm64 build for use with the newer
(faster) macos actions runners
Pass _var_data when creating LiteralVar

Partial fixes for reflex-dev#4608
@adhami3310
Copy link
Member

hey there! this seems like a positive change, but you should make sure the PR is rebased on main

@adhami3310
Copy link
Member

The PR is still not rebased properly (check the differences tab until it's only your changes).

@KronosDev-Pro
Copy link
Author

KronosDev-Pro commented Jan 12, 2025

The PR is still not rebased properly (check the differences tab until it's only your changes).

I know, the rebase is still local, I'm just making a few improvements.

@adhami3310 Maybe I need to recreate a new pr? because when I compare at this moment, everything is fine?

Details

@adhami3310
Copy link
Member

The PR is still not rebased properly (check the differences tab until it's only your changes).

I know, the rebase is still local, I'm just making a few improvements.

@adhami3310 Maybe I need to recreate a new pr? because when I compare at this moment, everything is fine?
Details

Maybe a new PR would help yea

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.