Documentation
¶
Index ¶
- Variables
- type CollectionMeta
- type NopStore
- func (*NopStore) Close() error
- func (*NopStore) GetBulletin(context.Context, string) (*vulners.Bulletin, error)
- func (*NopStore) GetCollectionMeta(context.Context) ([]CollectionMeta, error)
- func (*NopStore) GetLastSyncTime(context.Context, string) (time.Time, error)
- func (*NopStore) Purge(context.Context) error
- func (*NopStore) PutBulletins(context.Context, string, []vulners.Bulletin) error
- func (*NopStore) SearchBulletins(context.Context, string, int, int) ([]vulners.Bulletin, int, error)
- type SQLiteStore
- func (s *SQLiteStore) Close() error
- func (s *SQLiteStore) GetBulletin(ctx context.Context, id string) (*vulners.Bulletin, error)
- func (s *SQLiteStore) GetCollectionMeta(ctx context.Context) ([]CollectionMeta, error)
- func (s *SQLiteStore) GetLastSyncTime(ctx context.Context, collection string) (time.Time, error)
- func (s *SQLiteStore) Purge(ctx context.Context) error
- func (s *SQLiteStore) PutBulletins(ctx context.Context, collection string, bulletins []vulners.Bulletin) error
- func (s *SQLiteStore) SearchBulletins(ctx context.Context, query string, limit, offset int) ([]vulners.Bulletin, int, error)
- type Store
Constants ¶
This section is empty.
Variables ¶
ErrCacheUnavailable is returned by NopStore for write operations.
View Source
var ErrOfflineDataMissing = errors.New("offline data not synced; run 'vulners offline sync' first")
ErrOfflineDataMissing is returned when offline data is not cached.
Functions ¶
This section is empty.
Types ¶
type CollectionMeta ¶
type CollectionMeta struct {
Collection string `json:"collection"`
Count int `json:"count"`
SyncedAt time.Time `json:"syncedAt"`
}
CollectionMeta holds metadata about a synced collection.
type NopStore ¶
type NopStore struct{}
NopStore is a no-op Store returned when the cache database cannot be opened. Read operations return ErrOfflineDataMissing; write operations return ErrCacheUnavailable.
func (*NopStore) GetBulletin ¶
func (*NopStore) GetCollectionMeta ¶
func (*NopStore) GetCollectionMeta(context.Context) ([]CollectionMeta, error)
func (*NopStore) GetLastSyncTime ¶
func (*NopStore) PutBulletins ¶
type SQLiteStore ¶
type SQLiteStore struct {
// contains filtered or unexported fields
}
SQLiteStore implements Store using a SQLite database.
func NewSQLiteStore ¶
func NewSQLiteStore(dbPath string, logger *slog.Logger) (*SQLiteStore, error)
NewSQLiteStore opens or creates a SQLite cache at the given path.
func (*SQLiteStore) Close ¶
func (s *SQLiteStore) Close() error
func (*SQLiteStore) GetBulletin ¶
func (*SQLiteStore) GetCollectionMeta ¶
func (s *SQLiteStore) GetCollectionMeta(ctx context.Context) ([]CollectionMeta, error)
func (*SQLiteStore) GetLastSyncTime ¶
func (*SQLiteStore) PutBulletins ¶
type Store ¶
type Store interface {
GetBulletin(ctx context.Context, id string) (*vulners.Bulletin, error)
PutBulletins(ctx context.Context, collection string, bulletins []vulners.Bulletin) error
SearchBulletins(ctx context.Context, query string, limit, offset int) ([]vulners.Bulletin, int, error)
GetCollectionMeta(ctx context.Context) ([]CollectionMeta, error)
GetLastSyncTime(ctx context.Context, collection string) (time.Time, error)
Purge(ctx context.Context) error
Close() error
}
Store is the interface for the local cache.
Click to show internal directories.
Click to hide internal directories.