diff --git a/timeslots/kyoto_storage.go b/timeslots/kyoto_storage.go new file mode 100644 index 000000000..7d9b77bdb --- /dev/null +++ b/timeslots/kyoto_storage.go @@ -0,0 +1,27 @@ +package timeslots + +import ( + "log" + "github.com/fsouza/gokabinet/kc" +) + +type KyotoStorage struct { + db *kc.DB +} + +func NewKyotoStorage(filaName string) (*KyotoStorage, error) { + ndb, err := kc.Open(filaName, kc.READ) + log.Print("Starting kyoto storage") + return &KyotoStorage{db: ndb}, err +} + + +func (ks *KyotoStorage) Close() { + log.Print("Closing kyoto storage") + ks.db.Close() +} + +func (ks *KyotoStorage) Get(key string) (value string, err error) { + return ks.db.Get(key) +} + diff --git a/timeslots/redis_storage.go b/timeslots/redis_storage.go new file mode 100644 index 000000000..aa04906ab --- /dev/null +++ b/timeslots/redis_storage.go @@ -0,0 +1,28 @@ +package timeslots + +import ( + "log" + "github.com/simonz05/godis" +) + +type RedisStorage struct { + db *godis.Client +} + +func NewRedisStorage(address string) (*RedisStorage, error) { + ndb:= godis.New(address, 10, "") + log.Print("Starting redis storage") + return &RedisStorage{db: ndb}, nil +} + + +func (rs *RedisStorage) Close() { + log.Print("Closing redis storage") + rs.db.Quit() +} + +func (rs *RedisStorage) Get(key string) (string, error) { + elem, err := rs.db.Get(key) + return elem.String(), err +} + diff --git a/timeslots/storage_interface.go b/timeslots/storage_interface.go new file mode 100644 index 000000000..7d870327a --- /dev/null +++ b/timeslots/storage_interface.go @@ -0,0 +1,9 @@ +package timeslots + +/* +Interface for storage providers. +*/ +type StorageGetter interface { + Close() + Get(key string) (string, error) +} diff --git a/timeslots/timeslots.go b/timeslots/timeslots.go new file mode 100644 index 000000000..2f156a7e2 --- /dev/null +++ b/timeslots/timeslots.go @@ -0,0 +1,42 @@ +package timeslots + +import ( + "time" +) + +type BilingUnit int + +type RatingProfile struct { + StartTime time.Time + ConnectFee float32 + Price float32 + BillingUnit BilingUnit +} + +type ActivationPeriod struct { + ActivationTime time.Time + RatingProfiles []RatingProfile +} + +type Customer struct { + Id string + Prefix string + ActivationPeriods []ActivationPeriod +} + +const ( + SECONDS =iota + COUNT + BYTES +) + +type CallDescription struct { + tOR int + cstmId, subject, destination string + timeStart, timeEnd time.Time +} + +func GetCost(in *CallDescription, sg StorageGetter) (result string, err error) { + return "", nil +} + diff --git a/timeslots/timeslots_test.go b/timeslots/timeslots_test.go new file mode 100644 index 000000000..554b0cfa3 --- /dev/null +++ b/timeslots/timeslots_test.go @@ -0,0 +1,11 @@ +package timeslots + +func TestSimple(*testing.T){ + +} + +func BenchmarkSimple(b *testing.B) { + for i := 0; i < b.N; i++ { + GetCost() + } +} \ No newline at end of file