mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 10:06:24 +05:00
pointer fot interface
This commit is contained in:
@@ -5,7 +5,6 @@ import (
|
||||
"log"
|
||||
"net/http"
|
||||
"net/rpc"
|
||||
"time"
|
||||
"errors"
|
||||
)
|
||||
|
||||
@@ -28,20 +27,11 @@ func callRater(key string) (reply string) {
|
||||
log.Printf("Got en error from rater: %v", err)
|
||||
}
|
||||
}
|
||||
//log.Print(fmt.Sprintf("Result: %v", reply))
|
||||
return
|
||||
}
|
||||
|
||||
func testCallRater(key string){
|
||||
for {
|
||||
callRater(key)
|
||||
time.Sleep(1 * time.Second)
|
||||
}
|
||||
}
|
||||
|
||||
func main() {
|
||||
raterList = NewRaterList()
|
||||
//go testCallRater("test")
|
||||
raterList = NewRaterList()
|
||||
rpc.Register(raterList)
|
||||
rpc.HandleHTTP()
|
||||
|
||||
|
||||
20
src/loader/kyoto_loader.go
Normal file
20
src/loader/kyoto_loader.go
Normal file
@@ -0,0 +1,20 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/fsouza/gokabinet/kc"
|
||||
"flag"
|
||||
)
|
||||
|
||||
var (
|
||||
fileName = flag.String("fileName", "storage.kch", "kyoto storage file")
|
||||
)
|
||||
func main() {
|
||||
flag.Parse()
|
||||
db, _ := kc.Open(*fileName, kc.WRITE)
|
||||
defer db.Close()
|
||||
|
||||
db.Set("test", "12223")
|
||||
fmt.Println("Done!")
|
||||
}
|
||||
|
||||
@@ -7,5 +7,6 @@ GOFILES=\
|
||||
storage/interface.go\
|
||||
storage/kyoto_storage.go\
|
||||
storage/redis_storage.go\
|
||||
timestamps/timestamps.go\
|
||||
|
||||
include $(GOROOT)/src/Make.cmd
|
||||
|
||||
@@ -8,17 +8,17 @@ type KyotoStorage struct {
|
||||
db *kc.DB
|
||||
}
|
||||
|
||||
func NewKyotoStorage(filaName string) (KyotoStorage, error) {
|
||||
func NewKyotoStorage(filaName string) (*KyotoStorage, error) {
|
||||
ndb, err := kc.Open(filaName, kc.READ)
|
||||
return KyotoStorage{db: ndb}, err
|
||||
return &KyotoStorage{db: ndb}, err
|
||||
}
|
||||
|
||||
|
||||
func (ks KyotoStorage) Close() {
|
||||
func (ks *KyotoStorage) Close() {
|
||||
ks.db.Close()
|
||||
}
|
||||
|
||||
func (ks KyotoStorage) Get(key string) (value string, err error) {
|
||||
func (ks *KyotoStorage) Get(key string) (value string, err error) {
|
||||
return ks.db.Get(key)
|
||||
}
|
||||
|
||||
|
||||
@@ -8,17 +8,17 @@ type RedisStorage struct {
|
||||
db *godis.Client
|
||||
}
|
||||
|
||||
func NewRedisStorage(address string) (RedisStorage, error) {
|
||||
func NewRedisStorage(address string) (*RedisStorage, error) {
|
||||
ndb:= godis.New(address, 10, "")
|
||||
return RedisStorage{db: ndb}, nil
|
||||
return &RedisStorage{db: ndb}, nil
|
||||
}
|
||||
|
||||
|
||||
func (rs RedisStorage) Close() {
|
||||
func (rs *RedisStorage) Close() {
|
||||
rs.db.Quit()
|
||||
}
|
||||
|
||||
func (rs RedisStorage) Get(key string) (string, error) {
|
||||
func (rs *RedisStorage) Get(key string) (string, error) {
|
||||
elem, err := rs.db.Get(key)
|
||||
return elem.String(), err
|
||||
}
|
||||
|
||||
17
src/rater/timestamps/timestamps.go
Normal file
17
src/rater/timestamps/timestamps.go
Normal file
@@ -0,0 +1,17 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
type Rating struct {
|
||||
ConnectFeeIn time.Time
|
||||
PriceIn float32
|
||||
ConnectFeeOut time.Time
|
||||
PriceOut float32
|
||||
}
|
||||
|
||||
type Customer struct {
|
||||
Id string
|
||||
Prefix string
|
||||
}
|
||||
Reference in New Issue
Block a user