[racket-users] web-server dispatch and places

2015-12-01 Thread George Neuner

Hi all,

I'm not sure exactly how to phrase my questions, so let me give a bit of 
background.


I have a fairly large (and growing) web middleware application that uses 
serve/servlet and currently exposes about 90 function URLs, all of the 
form "/api//".   The application grew precipitously 
and right now there is a lot of duplication in the code - there are many 
instances of groups of functions within a "category" that can be 
implemented via a common parameter driven function.  I was hoping to 
refactor to use symbol-arg dispatch here practical.


I know the code can be refactored that way.  The problem is the 
"practical" part.



There are a small number of heavily used URL functions which I would 
like to separate out into a "place" which can be replicated to take 
advantage of multiple cores.  I have some good reasons [not relevant 
here] for not wanting to use separate processes.


Within a single servlet instance I know that dispatch rules are 
evaluated in order: e.g., in


:
[ ("api" "foo" "static")#:method "get" do-static  ]
[ ("api" "foo" (symbol-arg) #:method "get" do-dynamic ]
:

there is no problem handling "/api/foo/static" separately from other foo 
related URLs



However, continuing with this example, if  do-static  were moved into a 
separate place _listening on the same port_, then the symbol-arg version 
might erroneously capture and fail a request for the "static" version.



Making the places listen on separate ports is logistically complicated.  
My application hides behind Apache, which would need reconfiguration for 
every "special" ProxyPass URL whenever the application changed how it 
dispatched.  Although possible, mucking with Apache is inconvenient and 
yet-another-thing to remember to do.  It would be better if everything 
could be handled entirely within the Racket application.


I thought of keeping all the dispatch in one place, handing off specific 
functions to "worker" places.  But that too is problematic: the 
application is, in part, a specialized search engine ... the functions I 
want to separate can, and do, produce large amounts of data that would 
be impractical to relay through a common dispatcher place.


I thought of passing the TCP port to the worker place so it could 
respond directly.  I know the port is accessible inside response/output, 
but in that context it seems like it might be difficult to use a 
place(d) function to generate the response data. [Maybe not, I haven't 
tried it, but I'm concerned about trapping / handling / logging errors.]



It seems to make the most sense to have places dispatch their own set of 
requests.  However, if I want them to use the same listen port, it 
appears that I have to fully enumerate dispatch rule URLs - negating the 
possibility of using symbol-arg dispatch to handle commonalities.  
Obviously I can dispatch to stubs that redirect to a common function 
where possible, but it seems like there should be a less convoluted 
solution.


Am I missing something (obvious or not) ?Other, better ideas?


In any event, I thank everyone for "listening".  Just venting sometimes 
is helpful. :-)

George

--
You received this message because you are subscribed to the Google Groups "Racket 
Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[racket-users] Racket PPA updated for v6.3

2015-12-01 Thread Asumu Takikawa
Hi all,

For people who use Ubuntu, the PPA for Racket is now updated to v6.3:

  https://launchpad.net/~plt/+archive/ubuntu/racket

I've only tested it on Wily. Let me know if you find any problems.

Cheers,
Asumu

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] web-server dispatch and places

2015-12-01 Thread Robby Findler
You probably thought of this, but could you hand the ports themselves
over to the worker places after the dispatch but before any other
processing happened? Or maybe just make each place run the entire
server and then hand the ports over before dispatching and dispatch
inside each worker place?

Robby

On Tue, Dec 1, 2015 at 5:18 PM, George Neuner  wrote:
> Hi all,
>
> I'm not sure exactly how to phrase my questions, so let me give a bit of
> background.
>
> I have a fairly large (and growing) web middleware application that uses
> serve/servlet and currently exposes about 90 function URLs, all of the form
> "/api//".   The application grew precipitously and right
> now there is a lot of duplication in the code - there are many instances of
> groups of functions within a "category" that can be implemented via a common
> parameter driven function.  I was hoping to refactor to use symbol-arg
> dispatch here practical.
>
> I know the code can be refactored that way.  The problem is the "practical"
> part.
>
>
> There are a small number of heavily used URL functions which I would like to
> separate out into a "place" which can be replicated to take advantage of
> multiple cores.  I have some good reasons [not relevant here] for not
> wanting to use separate processes.
>
> Within a single servlet instance I know that dispatch rules are evaluated in
> order: e.g., in
>
> :
> [ ("api" "foo" "static")#:method "get" do-static  ]
> [ ("api" "foo" (symbol-arg) #:method "get" do-dynamic ]
> :
>
> there is no problem handling "/api/foo/static" separately from other foo
> related URLs
>
>
> However, continuing with this example, if  do-static  were moved into a
> separate place listening on the same port, then the symbol-arg version might
> erroneously capture and fail a request for the "static" version.
>
>
> Making the places listen on separate ports is logistically complicated.  My
> application hides behind Apache, which would need reconfiguration for every
> "special" ProxyPass URL whenever the application changed how it dispatched.
> Although possible, mucking with Apache is inconvenient and yet-another-thing
> to remember to do.  It would be better if everything could be handled
> entirely within the Racket application.
>
> I thought of keeping all the dispatch in one place, handing off specific
> functions to "worker" places.  But that too is problematic: the application
> is, in part, a specialized search engine ... the functions I want to
> separate can, and do, produce large amounts of data that would be
> impractical to relay through a common dispatcher place.
>
> I thought of passing the TCP port to the worker place so it could respond
> directly.  I know the port is accessible inside response/output, but in that
> context it seems like it might be difficult to use a place(d) function to
> generate the response data.  [Maybe not, I haven't tried it, but I'm
> concerned about trapping / handling / logging errors.]
>
>
> It seems to make the most sense to have places dispatch their own set of
> requests.  However, if I want them to use the same listen port, it appears
> that I have to fully enumerate dispatch rule URLs - negating the possibility
> of using symbol-arg dispatch to handle commonalities.  Obviously I can
> dispatch to stubs that redirect to a common function where possible, but it
> seems like there should be a less convoluted solution.
>
> Am I missing something (obvious or not) ?Other, better ideas?
>
>
> In any event, I thank everyone for "listening".  Just venting sometimes is
> helpful.  :-)
> George
>
> --
> You received this message because you are subscribed to the Google Groups
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to racket-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[racket-users] suggested default on warning

2015-12-01 Thread JCG
After having a silly runtime error of a missing argument, I wondered why arity 
wasn't checked (on hash-ref in my case).

Looking through old thread started by Roman Klochkov, I saw the answer to his 
and my identical question on arity checks.  I changed my logging to show in Dr 
Racket and included warnings on the list.  My immediate problem is solved.

My suggestion is that having a default of showing GC collection but not showing 
probable arity errors is misplaced.  For me, the GC information is noise.  
However, the arity check is very pertinent.  I understand that I can change the 
setting and I have.  However, I suspect that a review of those defaults would 
better assist the audience that is unlikely to have modified defaults.

Thanks for a wonderful environment.
John Griffin

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Hello everybody, i need help again :( sorry but i dont know much of Racket

2015-12-01 Thread Alejandro López
El lunes, 30 de noviembre de 2015, 19:02:35 (UTC-5), Matthias Felleisen 
escribió:
> Don't use the old X graphics library. Use
>  
>  #lang racket/gui 
> 
> instead. -- Matthias
> 
> 
> 
> On Nov 30, 2015, at 3:51 PM, Alejandro López  wrote:
> 
> > I have this code:
> > 
> > 
> > #lang racket
> > ;purpose
> > ;Creating play noughts and crosses
> > 
> > ;Include graphics library
> > (require (lib "Graphics.ss" "graphics"))
> > 
> > ;Open graphics library
> > (open-graphics)
> > 
> > ;Create window
> > (define window (open-viewport "three in one" 500 500))
> > 
> > ;background color
> > ((draw-viewport window) "black")
> > 
> > ;Give a name or title to the play in this case three in a row
> > ((draw-string window) (make-posn 200 75) "Tic Tac Toe" "white")
> > 
> > ; Draw the game board
> > ((draw-rectangle window) (make-posn 100 100) 100 100 "white")
> > ((draw-rectangle window) (make-posn 100 200) 100 100 "white")
> > ((draw-rectangle window) (make-posn 100 300) 100 100 "white")
> > ((draw-rectangle window) (make-posn 200 100) 100 100 "white")
> > ((draw-rectangle window) (make-posn 200 200) 100 100 "white")
> > ((draw-rectangle window) (make-posn 200 300) 100 100 "white")
> > ((draw-rectangle window) (make-posn 300 100) 100 100 "white")
> > ((draw-rectangle window) (make-posn 300 200) 100 100 "white")
> > ((draw-rectangle window) (make-posn 300 300) 100 100 "white")
> > 
> > ;Frames game
> > ((draw-rectangle window) (make-posn 95 95) 310 310 "white")
> > ((draw-rectangle window) (make-posn 50 50) 400 400 "white")
> > 
> > I have to make a game of " tic tac toe" and I have no idea how to make to 
> > click left of the mouse and show a square display an X and then another 
> > square to left click with the mouse and it then appears one O, and 
> > right-click on any square with a picture and let clean that square.
> > 
> > -- 
> > You received this message because you are subscribed to the Google Groups 
> > "Racket Users" group.
> > To unsubscribe from this group and stop receiving emails from it, send an 
> > email to racket-users+unsubscr...@googlegroups.com.
> > For more options, visit https://groups.google.com/d/optout.

But i need this in the old library

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Hello everybody, i need help again :( sorry but i dont know much of Racket

2015-12-01 Thread Alejandro López
But i need this in the old library :(

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] pasteboard% applications

2015-12-01 Thread Byron Davies
Thank you.  That’s very helpful.

> On Dec 1, 2015, at 10:20 PM, Benjamin Greenman  
> wrote:
> 
> I know of two (but I don't know them well)
> 
> The PLT card games library:
> https://github.com/racket/games/blob/master/cards/classes.rkt 
> 
> 
> Matthias's Acquire game:
> https://github.com/mfelleisen/Acquire/blob/master/tree-game.rkt 
> 
> 
> On Tue, Dec 1, 2015 at 10:39 PM, Byron Davies  > wrote:
> Does anyone have an application using pasteboard%?  I want to try one, and 
> I’d love to see an example.
> 
> Byron
> 
> Byron Davies, Ph.D.
> StarShine Academy International Schools
> Revolutionizing children’s learning. Seeking the Global Learning XPRIZE
> http://starshineplanet.com 
> 
> --
> You received this message because you are subscribed to the Google Groups 
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to racket-users+unsubscr...@googlegroups.com 
> .
> For more options, visit https://groups.google.com/d/optout 
> .
> 

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] pasteboard% applications

2015-12-01 Thread Benjamin Greenman
I know of two (but I don't know them well)

The PLT card games library:
https://github.com/racket/games/blob/master/cards/classes.rkt

Matthias's Acquire game:
https://github.com/mfelleisen/Acquire/blob/master/tree-game.rkt

On Tue, Dec 1, 2015 at 10:39 PM, Byron Davies 
wrote:

> Does anyone have an application using pasteboard%?  I want to try one, and
> I’d love to see an example.
>
> Byron
> 
> Byron Davies, Ph.D.
> StarShine Academy International Schools
> Revolutionizing children’s learning. Seeking the Global Learning XPRIZE
> http://starshineplanet.com
>
> --
> You received this message because you are subscribed to the Google Groups
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to racket-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[racket-users] send-generic vs send

2015-12-01 Thread Nota Poin
I don't really get what generics are. What is the difference between this:

(define show (generic window<%> show))

(send-generic a-window show #t)

and this:

(send a-window show #t)

If the former re...uses the (generic window<%> show) method to be "more" 
efficient, then why isn't show already a generic, and why don't we have (send) 
always use generics? Is it just that (send) existed before generics?

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[racket-users] Re: [racket] How to extend image-snip% with a new field

2015-12-01 Thread Guilherme Ferreira
Hello again,

I have a more concrete problem here. The following class
extends the image-snip% with a float (size), and overrides
the methods copy and write as supposed.

(define extend-snip%
  (class image-snip%
(init-field [size 20.0])
(super-new)

(define/override (copy)
  (new circle-snip% [size size]))
 
(define/override (write f)
  (send f put size

But when I create an object of this class, for example:

> (make-object extend-snip% 30 "~/Documents/img.png")

I expected to see the bitmap here (wrapped in this class)

However, it throws the following error: 

draw-rectangle: contract violation
  expected: (not/c negative?)
  given: -2.0
...

Someone can give me a more useful explanation?

Thanks.

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] "bad variable linkage" after restarting handin server under load

2015-12-01 Thread Paolo Giarrusso
Hi!
After a new deadline, I got good news and bad news.

# Good news

I think *this* bug is fixed. Evidence: instead of crashing at the
first reboot under load, the server survived to 10-20 automated
reboots with the students submitting en masse without never showing
the bug. So not only the patch makes sense, but it seems to be for the
same bug.

# Bad news

The setup still didn't scale, though this wasn't as bad, and part of
it was due to my setup. One student compared it to new releases from
Blizzard. While our beefy server isn't even remotely sweating O_O.

So I'd like to understand Racket threads and the handin server, to
plan accordingly:

- Does the whole handin server actually run on *one* processor,
because of Racket multithreading?
- What's your largest deployment with active checkers?
- Do you actually use this for HtDP courses, or only for advanced
classes (as a number of signs suggest)?

1. Under load, requesting the home page takes more than 20 seconds, so
my watchdog scripts restarts the server. We have a watchdog script
because when we didn't, the server just hung sometimes, so for our
previous lecture (smaller, only ~100 students instead of 500, and no
checkers) this watchdog script did wonders.
2. Here's the watchdog:
curl --max-time 20 -s
https://handin-ps.informatik.uni-tuebingen.de:7979/ > /dev/null || {
docker restart handin-server-production; }
That's even running every minute :-(

Usually that request takes 20 ms, so (naive me thought) how on Earth
could this balloon to 20 seconds?
Now that I know of Racket threads, I understand: that includes both
the web server and the checkers, together with an unspecified number
of big-bang instances from students. For extra fun, one students
called animate with big-bang as step function — essentially, a sweet
HtDP fork bomb.

I don't expect a patch for this, I'm just trying to understand things
and contemplating workarounds, beyond a more lenient watchdog (or
disabling it altogether and acting by hand), which I guess won't be
enough.

Cheers,
Paolo

On 29 November 2015 at 16:12, Robby Findler  wrote:
>
>
> On Sunday, November 29, 2015, Paolo Giarrusso  wrote:
>>
>> On Friday, November 27, 2015 at 3:44:20 AM UTC+1, Robby Findler wrote:
>> > Yes, I think you're right. I originally wrote that because I was
>> > thinking that this code might be involved in evaluating the user's
>> > submission, but I am not pretty sure I was wrong about that.
>>
>> "not pretty sure"?
>
>
> Sorry. No "not".
>
>
>>
>>
>> AFAICS, `auto-reload-value` is used to extract the `checker` binding from
>> the various checker.rkt. but the lock will not be held while running
>> `checker`. (Luckily we're not using hooks, I haven't studied that code).
>
>
> Yes that's also what I noticed and why I sent a second diff. Or did I miss
> another place?

Was just rechecking because of the above confusion. We agree.

-- 
Paolo G. Giarrusso - Ph.D. Student, Tübingen University
http://ps.informatik.uni-tuebingen.de/team/giarrusso/

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.