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

proposal: scenes #27

Open
vitaliy-ukiru opened this issue Jun 9, 2024 · 0 comments
Open

proposal: scenes #27

vitaliy-ukiru opened this issue Jun 9, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@vitaliy-ukiru
Copy link
Owner

vitaliy-ukiru commented Jun 9, 2024

Scenes - abstraction on normal states. It helps hand over on repetitive actions to module control.

What scenes will do

  1. Start scene on trigger
  2. Gives possiblity to easy change steps.
  3. Start sub scene (maybe it don't in release)
  4. Execute scene in one command from code
  5. Save data between steps
  6. Data flow between scenes

Topic 0. Goals

I want to make mechanism that helps convert scenes to more declarative code.
Why? Maybe it helps write less repeatable code. But then public API will more complex.
Need to find balance

Actions

Entrypoints

Entrypoints must filter (endpoint and/or filters) and may be send some information on fails.
It will "generated" handlers.

Stop points

This points, just stops scene. No actions.

Events callbacks

Avaliable callbacks: OnStart, OnFinish, OnStop.

Callbacks OnStart and OnStop will calls after handler-points.

Steps - Enter

Steps can do some work when user moving to this step. It can'be information for excepted data or something like that.
It need for don't do this in previous step. Like that

step_1() {
   do_smth()
   send("Enter your name")
   next_step()
}

These callbacks can'be disabled in changing step command.

Topic 1. Interface

I tried to write my vision of public API but it gets wordy and hard to read.
I think need look towards option-func or inner callbacks.

Topic 2. Data storage

It pretty then you have easy access to data.
Now supports generic and it can help. Scene can work with pre-declarated type of data. May be data-storage will separated from state storage.

But it also make API ugly.

Topic 3. Sub scenes.

Sub scenes will only runtime feature. I don't known that write here...

Topic 4. History

For error handling and debugging make sense do mechanism for tracing user actions.
It will be collect all errors, steps moves.

Scenes will communicate via errors. For example, if user make bad action it's error and scene can stops with error, that can'be have sense only in logs.

How I'm sees logs:

Scene: MyScene
Start: 
  EntryPoint: /scene
Stop: unexpected error from step 'check_name': db: connection refused 
Traceback:
      [0]: EntryPoint: /scene
            Update: {json of telegram update}
      [1]: Step: accept_tos
            Update: ...
      [2]: Step: enter name
            Update: ...
            Repeat-Step: "invalid format of name"
      [2]: Step: enter name
            Error: 
               Unexpected: "db: connection-refused"
            Action: Stop-Scene   
      [OnStop]: Make: ResetData
@vitaliy-ukiru vitaliy-ukiru added the enhancement New feature or request label Jun 9, 2024
@vitaliy-ukiru vitaliy-ukiru pinned this issue Jun 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant