Skip to content

feat: Export Handlers (req, resp, https)#445

Open
guilhem wants to merge 3 commits intoelazarl:masterfrom
guilhem:export-handlers
Open

feat: Export Handlers (req, resp, https)#445
guilhem wants to merge 3 commits intoelazarl:masterfrom
guilhem:export-handlers

Conversation

@guilhem
Copy link
Copy Markdown

@guilhem guilhem commented Jul 15, 2021

This is usufull when handlers will be dynamicaly created and removed.

This is usufull when handlers will be dynamicaly created and removed.
@guilhem guilhem changed the title feat: Export Handlers (req, rest, https) feat: Export Handlers (req, resp, https) Jul 15, 2021
@elazarl
Copy link
Copy Markdown
Owner

elazarl commented Jul 16, 2021

Can you please explain why you can't use the existing methods to manipulate the handlers?

Making a private field public is risky, as it cannot be undone.

@guilhem
Copy link
Copy Markdown
Author

guilhem commented Jul 16, 2021

@elazarl in current implementation, Handlers are manipulated by .Do(, .HijackConnect(, .HandleConnect( and only with an = append(.
It makes impossible to remove elements or to know what are elements inside.

What I need is to Add / List and Remove handlers to be able to do it dynamically (at run-time).

@guilhem
Copy link
Copy Markdown
Author

guilhem commented Jul 27, 2021

This permit to update content without edgecases

Signed-off-by: Guilhem Lettron <guilhem@barpilot.io>
@elazarl
Copy link
Copy Markdown
Owner

elazarl commented Jan 31, 2022

I don't see why you need indirection. Making them public should be good enough.

Slice is already a pointer.

Also not sure how you handle concurrency.

@guilhem
Copy link
Copy Markdown
Author

guilhem commented Jan 31, 2022

I don't see why you need indirection. Making them public should be good enough.

Slice is already a pointer.

Also not sure how you handle concurrency.

I totally agree with you.
But I faced a lot of problems with slices and make it working with pointer. 🤷‍♂️
I need to do more tests.

I also find this article, not sure if applicable: https://medium.com/swlh/golang-tips-why-pointers-to-slices-are-useful-and-how-ignoring-them-can-lead-to-tricky-bugs-cac90f72e77b

@guilhem
Copy link
Copy Markdown
Author

guilhem commented Feb 8, 2022

@elazarl I did more tests and slice is not updated if it's not a pointer.
Having a pointer also have some interest, it's possible to update content atomically. Just create a new slice with right content and update pointer in 1 step.

@elazarl
Copy link
Copy Markdown
Owner

elazarl commented Feb 27, 2024

@guilhem what I suggest is, add a single handler that has internal handlers, and handle concurrency inside

We'll add this as an extension.

What do you think?

@guilhem
Copy link
Copy Markdown
Author

guilhem commented Mar 2, 2024

@guilhem what I suggest is, add a single handler that has internal handlers, and handle concurrency inside

We'll add this as an extension.

What do you think?

I will try to do this solution :)

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.

2 participants