Skip to content

Class diagram #341

Open
Open

Description

@bluetech

All of the Hook* classes are somewhat confusing to me, and I always have to rediscover how they relate. So I created an ASCII diagram of it. I think it's worth shoving in a comment somewhere, or in some "architecture" document. I'll use this issue as a placeholder for that.

                                                 ┌──────────┐
                                                 │ HookSpec │
                                                 └──────────┘
                                                       ▲       plugin1    ┌────────┐
                                                       │  ┌──────────────►│HookImpl│
                                                       │  │               └────────┘
                                       foo_hook1 ┌─────┴──┴─┐
                                      ┌──────────┤HookCaller├───►...
                                      │          └────────┬─┘
                                      │                   │               ┌────────┐
                                      │                   └──────────────►│HookImpl│
                                      │                        plugin2    └────────┘
    ┌─────────────┐  pm.hook  ┌───────┴─┐
    │PluginManager├──────────►│HookRelay├───►...
    └─────────────┘           └───────┬─┘
                                      │                        plugin2    ┌────────┐
                                      │                  ┌───────────────►│HookImpl│
                                      │                  │                └────────┘
                                      │          ┌───────┴──┐
                                      └─────────►│HookCaller├───►...
                                       foo_hook2 └─────┬─┬──┘
                                                       │ │                ┌────────┐
                                                       │ └───────────────►│HookImpl│
                                                       ▼       plugin3    └────────┘
                                                 ┌──────────┐
                                                 │ HookSpec │
                                                 └──────────┘

Activity

  1. self-assigned this
    on Jan 10, 2022
  2. RonnyPfannschmidt commented on Jan 11, 2022

    @RonnyPfannschmidt
    Member

    Maybe we should plntuml this

  3. bluetech commented on Jan 14, 2022

    @bluetech
    MemberAuthor

    Just saw this github/roadmap#372 which is similar to planetuml, I might try it.

    Leaving their example here to see when it actually works :)

    graph TD;
        A-->B;
        A-->C;
        B-->D;
        C-->D;
    
    Loading
  4. RonnyPfannschmidt commented on Jan 14, 2022

    @RonnyPfannschmidt
    Member

    sounds fun, will wait for that then,

  5. Northxw commented on Mar 10, 2022

    @Northxw

    All of the Hook* classes are somewhat confusing to me, and I always have to rediscover how they relate. So I created an ASCII diagram of it. I think it's worth shoving in a comment somewhere, or in some "architecture" document. I'll use this issue as a placeholder for that.

                                                     ┌──────────┐
                                                     │ HookSpec │
                                                     └──────────┘
                                                           ▲       plugin1    ┌────────┐
                                                           │  ┌──────────────►│HookImpl│
                                                           │  │               └────────┘
                                           foo_hook1 ┌─────┴──┴─┐
                                          ┌──────────┤HookCaller├───►...
                                          │          └────────┬─┘
                                          │                   │               ┌────────┐
                                          │                   └──────────────►│HookImpl│
                                          │                        plugin2    └────────┘
        ┌─────────────┐  pm.hook  ┌───────┴─┐
        │PluginManager├──────────►│HookRelay├───►...
        └─────────────┘           └───────┬─┘
                                          │                        plugin2    ┌────────┐
                                          │                  ┌───────────────►│HookImpl│
                                          │                  │                └────────┘
                                          │          ┌───────┴──┐
                                          └─────────►│HookCaller├───►...
                                           foo_hook2 └─────┬─┬──┘
                                                           │ │                ┌────────┐
                                                           │ └───────────────►│HookImpl│
                                                           ▼       plugin3    └────────┘
                                                     ┌──────────┐
                                                     │ HookSpec │
                                                     └──────────┘
    

    I was lucky to see this flowchart, which can be said to be a simple illustration of the core calling logic of pluggy. If you need to continue improving, or have something to help with, I'd be happy to do some!

  6. nicoddemus commented on Mar 10, 2022

    @nicoddemus
    Member

    Gave it a quick go, just to see if it has potential:

    flowchart LR
      PluginManager -.- pm.hook --> HookRelay
      HookRelay -- foo_hook --> HookCaller --> HookSpec
      HookRelay -- foo_hook2 --> HookCaller -- plugin1 --> HookImpl1
      HookCaller -- plugin2 --> HookImpl2
    
    Loading

    Looks nice! https://mermaid-js.github.io/mermaid

  7. bluetech commented on Mar 13, 2022

    @bluetech
    MemberAuthor

    Thanks for converting @nicoddemus!

    It does lose some details - namely it merges the nodes when it's better not, the placing of the HookSpec and the .... Maybe this can be added in though. I'll need to learn the mermaid syntax.

  8. CofinCup commented on Jul 26, 2022

    @CofinCup

    [off topic]
    Is it possible that we use a class structure like this? Or are there specialised intentions?
    I mean, the HookRelay class seemed meaningless to me...

                                   ┌──────────┐
                                   │ HookSpec │
                                   └──────────┘
                                         ▲       plugin1    ┌────────┐
                                         │  ┌──────────────►│HookImpl│
                                         │  │               └────────┘
                         pm.hook1  ┌─────┴──┴─┐
                        ┌──────────┤HookCaller├───►...
                        │          └────────┬─┘
                        │                   │               ┌────────┐
                        │                   └──────────────►│HookImpl│
                        │                        plugin2    └────────┘
    ┌─────────────┐     |
    │PluginManager|-----|
    └─────────────┘     |
                        │                        plugin2    ┌────────┐
                        │                  ┌───────────────►│HookImpl│
                        │                  │                └────────┘
                        │          ┌───────┴──┐
                        └─────────►│HookCaller├───►...
                         pm.hook2  └─────┬─┬──┘
                                         │ │                ┌────────┐
                                         │ └───────────────►│HookImpl│
                                         ▼       plugin3    └────────┘
                                   ┌──────────┐
                                   │ HookSpec │
                                   └──────────┘
    
  9. bluetech commented on Aug 5, 2023

    @bluetech
    MemberAuthor

    @CofinCup HookRelay does seem redundant but I think the main problem it solves is that hook names don't conflict with PluginManager method/attribute names.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions