-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Kyl Wellman
committed
Jan 6, 2016
1 parent
140e670
commit a2a865c
Showing
4 changed files
with
94 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,4 +3,8 @@ bin | |
pkg | ||
|
||
# IDK where this comes from | ||
src/uri.txt | ||
uri.txt | ||
|
||
# VIM | ||
*~ | ||
*.swp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package engineroom | ||
|
||
import ( | ||
"encoding/base64" | ||
"fmt" | ||
"github.com/nadroz/azure-sdk-for-go/storage" | ||
) | ||
|
||
func Peek(queueName string) { | ||
client := getStorageClient() | ||
params := storage.PeekMessagesParameters{ | ||
NumOfMessages: 1, | ||
} | ||
|
||
messages, err := client.PeekMessages(queueName, params) | ||
if err != nil { | ||
fmt.Printf("Failed to peek messages: %s\n", err) | ||
return | ||
} | ||
|
||
if len(messages.QueueMessagesList) != 1 { | ||
return | ||
} | ||
|
||
msg := messages.QueueMessagesList[0] | ||
|
||
txt, err := base64.StdEncoding.DecodeString(msg.MessageText) | ||
|
||
if err != nil { | ||
fmt.Printf("Failed to decode message: %s\n", err) | ||
return | ||
} | ||
|
||
fmt.Printf("%s\n", txt) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package engineroom | ||
|
||
import ( | ||
"encoding/base64" | ||
"fmt" | ||
"github.com/nadroz/azure-sdk-for-go/storage" | ||
) | ||
|
||
func Pop(queueName string) { | ||
client := getStorageClient() | ||
params := storage.GetMessagesParameters{ | ||
NumOfMessages: 1, | ||
VisibilityTimeout: 30, | ||
} | ||
|
||
messages, err := client.GetMessages(queueName, params) | ||
if err != nil { | ||
fmt.Printf("Failed to pop message: %s\n", err) | ||
return | ||
} | ||
|
||
if len(messages.QueueMessagesList) != 1 { | ||
return | ||
} | ||
|
||
msg := messages.QueueMessagesList[0] | ||
|
||
err = client.DeleteMessage(queueName, msg.MessageID, msg.PopReceipt) | ||
|
||
if err != nil { | ||
fmt.Printf("Failed to pop message: %s\n", err) | ||
} | ||
|
||
txt, err := base64.StdEncoding.DecodeString(msg.MessageText) | ||
|
||
if err != nil { | ||
fmt.Printf("Failed to decode message: %s\n", err) | ||
return | ||
} | ||
|
||
fmt.Printf("%s\n", txt) | ||
} |