mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
rater docs
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
package main
|
||||
|
||||
/*
|
||||
Interface for storage providers.
|
||||
*/
|
||||
type StorageGetter interface {
|
||||
Close()
|
||||
Get(key string) (string, error)
|
||||
|
||||
Reference in New Issue
Block a user