planner/plan/storage/storage.go

68 lines
1.2 KiB
Go
Raw Normal View History

2024-09-30 07:34:40 +02:00
package storage
2024-10-03 07:32:48 +02:00
import (
"errors"
)
var (
ErrNotFound = errors.New("not found")
)
2024-12-22 11:43:37 +01:00
// type LocalID interface {
// FindAll() (map[string]int, error)
// FindOrNext(id string) (int, error)
// Next() (int, error)
// Store(id string, localID int) error
// Delete(id string) error
// }
2024-10-03 07:32:48 +02:00
2024-12-22 11:43:37 +01:00
// type Sync interface {
// FindAll() ([]item.Item, error)
// Store(i item.Item) error
// DeleteAll() error
// LastUpdate() (time.Time, error)
// }
2024-10-07 11:11:18 +02:00
2024-12-22 11:43:37 +01:00
// type Event interface {
// Store(event item.Event) error
// Find(id string) (item.Event, error)
// FindAll() ([]item.Event, error)
// Delete(id string) error
// }
2024-10-03 07:32:48 +02:00
2024-12-22 11:43:37 +01:00
// func NextLocalID(used []int) int {
// if len(used) == 0 {
// return 1
// }
2024-10-03 07:32:48 +02:00
2024-12-22 11:43:37 +01:00
// sort.Ints(used)
// usedMax := 1
// for _, u := range used {
// if u > usedMax {
// usedMax = u
// }
// }
2024-10-03 07:32:48 +02:00
2024-12-22 11:43:37 +01:00
// var limit int
// for limit = 1; limit <= len(used) || limit < usedMax; limit *= 10 {
// }
2024-10-03 07:32:48 +02:00
2024-12-22 11:43:37 +01:00
// newId := used[len(used)-1] + 1
// if newId < limit {
// return newId
// }
2024-10-03 07:32:48 +02:00
2024-12-22 11:43:37 +01:00
// usedMap := map[int]bool{}
// for _, u := range used {
// usedMap[u] = true
// }
2024-10-03 07:32:48 +02:00
2024-12-22 11:43:37 +01:00
// for i := 1; i < limit; i++ {
// if _, ok := usedMap[i]; !ok {
// return i
// }
// }
2024-10-03 07:32:48 +02:00
2024-12-22 11:43:37 +01:00
// return limit
// }