rater docs

This commit is contained in:
Radu Ioan Fericean
2012-01-28 19:02:23 +02:00
parent 105c082556
commit 5bf90c6fb4
3 changed files with 18 additions and 0 deletions

View File

@@ -22,11 +22,17 @@ func NewStorage(nsg StorageGetter) *Storage{
return &Storage{sg: nsg}
}
/*
RPC method providing the rating information from the storage.
*/
func (s *Storage) Get(args string, reply *string) (err error) {
*reply, err = s.sg.Get(args)
return err
}
/*
RPC method that trigers rater shutdown in case of server exit.
*/
func (s *Storage) Shutdown(args string, reply *string) (err error) {
s.sg.Close()
defer os.Exit(0)

View File

@@ -8,6 +8,9 @@ import (
"syscall"
)
/*
Listens for the SIGTERM, SIGINT, SIGQUIT system signals and gracefuly unregister from inquirer and closes the storage before exiting.
*/
func StopSingnalHandler(server, listen *string, getter *KyotoStorage) {
log.Print("Handling stop signals...")
sig := <-signal.Incoming
@@ -22,6 +25,9 @@ func StopSingnalHandler(server, listen *string, getter *KyotoStorage) {
}
}
/*
Connects to the inquirer and calls unregister RPC method.
*/
func unregisterFromServer(server, listen *string) {
client, err := rpc.DialHTTP("tcp", *server)
if err != nil {
@@ -37,6 +43,9 @@ func unregisterFromServer(server, listen *string) {
}
}
/*
Connects to the inquirer and rehisters the rater to the server.
*/
func RegisterToServer(server, listen *string) {
client, err := rpc.DialHTTP("tcp", *server)
if err != nil {

View File

@@ -1,5 +1,8 @@
package main
/*
Interface for storage providers.
*/
type StorageGetter interface {
Close()
Get(key string) (string, error)