Permalink
Browse files

started with new thumbnail generation interface

  • Loading branch information...
1 parent 9f068af commit efb1c881346b048bc08952d1f24e2a2fe0ed83cb @hukl committed Dec 1, 2012
Showing with 24 additions and 1 deletion.
  1. +1 −1 app/models/url.rb
  2. +23 −0 lib/thumbnail_client.rb
View
@@ -93,7 +93,7 @@ def create_image_uuid
end
def create_thumbnail
- Resque.enqueue( Thumbnail, self.uri, self.image_uuid )
+ ThumbnailClient.reqeust( self.uri, self.image_uuid )
end
def delete_from_index
View
@@ -0,0 +1,23 @@
+module ThumbnailClient
+ def intialize
+ @udp_socket ||= UDPSocket.new
+ end
+
+ def request(uri, image_uuid)
+ host = "127.0.0.1"
+ port = 8789
+
+ # <<UriLength:16/big,Uri:UriLength/binary,UudiLength:16/big,Uudi:UuidLength/binary>>
+ packet = [uri.length, uri, image_uuid.length, image_uuid].pack(
+ "nA*#{uri.length}nA*#{image_uuid.length}"
+ )
+
+ @udp_socket.send( packet, 0, proxy_host, proxy_port )
+ rescue
+ if udp_socket.closed?
+ @udp_socket = UDPSocket.new
+ end
+
+ false
+ end
+end

0 comments on commit efb1c88

Please sign in to comment.