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

feat: full support middleware #16

Merged
merged 23 commits into from
Sep 8, 2023
Merged

Conversation

vitaliy-ukiru
Copy link
Owner

@vitaliy-ukiru vitaliy-ukiru commented Sep 8, 2023

The main problem was where the fsm handler was converted to telebot. Initially there was no way to bind middlewares.

Now the mechanism of fsm context delivery to handlers has changed. This is done via wrapperContext.
See Manager.adapt, Manager.forEndpoint, Manager.handle and wrap_tele_context.go for details.

There may be slight performance sags since type assertions are now used.
The external API has remained the same.

Problems

[ 1 ] fsm internal key

May be change fsmInternalKey to same with middleware.ContexKey, it will additional support.

[ 2 ] Manager.adapt & Manager.HandlerAdapter

Methods do something same, but first have 'optimistic' branch to extract FSM Context from telebot context.
But in bad variant it also allocates new FSM context.

[ 3 ] Sub group manager method name

Now it names 'Child'. Thinked rename to NewGroup, but it breake prev. semantic.
Though it's more likely that it doesn't break, - but fixes the originally intended semantics.

For support middlewares in handlers we need packs middlewares independently of telebot.
This wrapper storages fsm context inside, that gives possible provides context to handlers.

feat: #15 support middlewares
This change allows you to change the behavior of fsm context retrieval without using many pointers.

feat: #15 support middlewares
feat: #15 support middlewares
@vitaliy-ukiru vitaliy-ukiru added documentation Improvements or additions to documentation enhancement New feature or request tests some tests changes expirement some expiremental functional labels Sep 8, 2023
@vitaliy-ukiru vitaliy-ukiru self-assigned this Sep 8, 2023
@vitaliy-ukiru
Copy link
Owner Author

vitaliy-ukiru commented Sep 8, 2023

problem [ 3 ]

name will NewGroup
todo

  • Replace logic to NewGroup from Child
  • Delete deprecated point
  • update docs

@vitaliy-ukiru
Copy link
Owner Author

problem [ 2 ]

leave it as it is for now

problem [ 1 ]

the same will not be changed, as the semantics of ContextMaker may be affected.

@vitaliy-ukiru vitaliy-ukiru merged commit 18ae925 into master Sep 8, 2023
4 checks passed
@vitaliy-ukiru vitaliy-ukiru deleted the feat/full-support-middleware branch November 26, 2023 12:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement New feature or request expirement some expiremental functional tests some tests changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant