Skip to content
This repository has been archived by the owner on Aug 5, 2019. It is now read-only.

Nowin not providing "host.OnAppDisposing" CancellationToken #36

Open
pysco68 opened this issue Jun 29, 2015 · 7 comments
Open

Nowin not providing "host.OnAppDisposing" CancellationToken #36

pysco68 opened this issue Jun 29, 2015 · 7 comments

Comments

@pysco68
Copy link

pysco68 commented Jun 29, 2015

Hello,

I'm currently trying to migrate an existing OWIN application to be hosted with Nowin. It worked mostly flawlessly (and with good performance results). However on of the last missing pieces is that Nowin seemingly doesn't provide a CancellationToken under the key host.OnAppDisposing in the application dictionary.

This cancellation token can be used to hook into the disposal process of the application, which can be very useful to dispose things like singletons that were instantiated during the web-application's setup, whitout having to build-up too much messy code.

If you could pinpoint where I should look at to implement the missing parts I'd be happy to contribute to this great project!

Here's some information about the topic:

@pysco68 pysco68 changed the title Nowin not providing OnAppDisposing CancellationToken Nowin not providing "host.OnAppDisposing" CancellationToken Jun 29, 2015
@Bobris
Copy link
Owner

Bobris commented Jun 29, 2015

Hi,

This is actually not really part of official Owin standart, so it would be nice is you would add it if you need it :-)
I think all changes should be limited to https://github.com/Bobris/Nowin/blob/master/Nowin/OwinServerFactory.cs
and
https://github.com/Bobris/Nowin/blob/master/Nowin/OwinKeys.cs

@pysco68
Copy link
Author

pysco68 commented Jun 29, 2015

I'd really like to give this a try (or even better implement server.OnDispose as they are mentioned in the official specification: https://github.com/owin/owin/blob/master/CommonKeys.md). I've looked at the code for some while now, and I struggle a bit to find the right place(s) to put that in.

My question: In my understanding the CancellationToken should be reachable via both IAppBuilder.Properties and the request environment. Is this a correct interpretation of the specification?

@Bobris
Copy link
Owner

Bobris commented Jun 29, 2015

It could be in that capabilities dictionary. You get them in each request, but I don't think it should be usefull there for anything (https://github.com/Bobris/Nowin/blob/master/Nowin/OwinEnvironment.Generated.tt#L29), you already have owin.CallCanceled

@Bobris
Copy link
Owner

Bobris commented Jun 29, 2015

And how to find out that server is disposing just subscribe in https://github.com/Bobris/Nowin/blob/master/Nowin/OwinServerFactory.cs#L79

@serialseb
Copy link
Contributor

server.OnInit and server.OnDispose have been standardized. The microsoft key is mentioned as a backward compatibility thing. See owin/owin#27

@Bobris
Copy link
Owner

Bobris commented Jul 14, 2015

@serialseb Problem is that Nowin is just server not host or builder, so I am no sure to which Dictionary I should place this (in per request it would be for sure useless. If you know about some sample implementation I could learn from how to do it, I am also interested.

@serialseb
Copy link
Contributor

startup properties exist during wireup (if you support BuildFunc), and contain all the common keys "available at startup", as per CommonKeys. The env contains startup keys and the http request associated keys.

In other words, anything that ought to be exposed as a startup key ought to be in its own dictionary, and any key per request / response ought to be in the env dictionary, which contains all the startup keys.

The upcoming 1.0.1 spec will clarify those things.

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

No branches or pull requests

3 participants