Skip to content

set_rotate #8

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

Merged
merged 2 commits into from
Apr 17, 2012
Merged

set_rotate #8

merged 2 commits into from
Apr 17, 2012

Conversation

viperet
Copy link

@viperet viperet commented Mar 30, 2012

Hi! I've a new dirrective set_rotate $value $from $to, which "rotates" $value in range $from - $to
Sample config:

   location /rotate {
       default_type text/plain;
       set $counter $cookie_counter;
       set_rotate $counter 1 5;
       echo $counter;
       add_header Set-Cookie counter=$counter;
   }                                                                                                      

Accessing "/rotate" will display numbers from 1 to 5 in cycle. I use this directive for rotating banners.
I've added some basic documentation to doc/HttpSetMiscModule.wiki

@agentzh
Copy link
Member

agentzh commented Mar 31, 2012

This looks very interesting :) I'll merge your patches later when I have some time ;) Thank you for your contribution!

@agentzh
Copy link
Member

agentzh commented Apr 17, 2012

Sorry for the delay! It seems to me that another interesting feature here is when $counter is uninitialized, i.e., not found or just empty strings, then we could use a persistent state in the nginx worker process level, such that we can do round-robin dispatch for upstreams.

Also, will you submit some test cases for this new feature?

Thank you!

@agentzh
Copy link
Member

agentzh commented Apr 17, 2012

No worries, I'm already working on these :)

@agentzh
Copy link
Member

agentzh commented Apr 17, 2012

I've fixed various coding style issues and typos in your patches:

https://github.com/agentzh/set-misc-nginx-module/commit/9e061396

I've also added some test cases for this new directive.

I'll then work on the persistent rotating state for this directive when there is no "current value" given.

@agentzh
Copy link
Member

agentzh commented Apr 17, 2012

I've already made the "current value" persistent and set_rotate will use it when the current value is not given or is given a bad value. See the patch here:

https://github.com/agentzh/set-misc-nginx-module/commit/9792e8d

Does it look good for you?

@agentzh
Copy link
Member

agentzh commented Apr 17, 2012

The "current value" persistence is also on a per-location basis, see the following (passing) test case:

1c8e3ef

@viperet
Copy link
Author

viperet commented Apr 17, 2012

Thanks for correcting and fixing my code.

Does it look good for you?

It's very good to me!

@agentzh agentzh merged commit f091d5b into openresty:master Apr 17, 2012
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