From 5bf90c6fb4c9febdfd08ffd2587793f8a01e2668 Mon Sep 17 00:00:00 2001 From: Radu Ioan Fericean Date: Sat, 28 Jan 2012 19:02:23 +0200 Subject: [PATCH] rater docs --- cmd/rater/rater.go | 6 ++++++ cmd/rater/registration.go | 9 +++++++++ cmd/rater/storage_interface.go | 3 +++ 3 files changed, 18 insertions(+) diff --git a/cmd/rater/rater.go b/cmd/rater/rater.go index 84e6bcac8..7009ea2ad 100644 --- a/cmd/rater/rater.go +++ b/cmd/rater/rater.go @@ -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) diff --git a/cmd/rater/registration.go b/cmd/rater/registration.go index e46968a53..faaaef1df 100644 --- a/cmd/rater/registration.go +++ b/cmd/rater/registration.go @@ -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 { diff --git a/cmd/rater/storage_interface.go b/cmd/rater/storage_interface.go index e4f0ad6cd..87054eb22 100644 --- a/cmd/rater/storage_interface.go +++ b/cmd/rater/storage_interface.go @@ -1,5 +1,8 @@ package main +/* +Interface for storage providers. +*/ type StorageGetter interface { Close() Get(key string) (string, error)