Skip to content

Instantly share code, notes, and snippets.

@soheilhy
soheilhy / queue.go
Created July 22, 2015 00:56
Register HTTP Handlers
// RegisterTaskQ registers the taskq application and all its handler in the
// hive.
func RegisterTaskQ(h beehive.Hive) {
a := h.NewApp("taskq", beehive.Persistent(3))
a.Handle(Enque{}, EnQHandler{})
a.Handle(Deque{}, DeQHandler{})
a.Handle(Ack{}, AckHandler{})
a.Handle(Timeout{}, TimeoutHandler{
ExpDur: 60 * time.Second,
})
@soheilhy
soheilhy / cmux_example.go
Last active August 29, 2015 14:26
cmux example
// Create the main listener.
lis, err := net.Listen("tcp", ":23456")
if err != nil {
log.Fatal(err)
}
// Create a cmux.
mux := cmux.New(lis)
// Match connections in order:
@soheilhy
soheilhy / server.go
Created August 1, 2015 16:41
grpc route guide server + cmux
/*
*
* Copyright 2015, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright