-
Notifications
You must be signed in to change notification settings - Fork 183
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Convert default backend from "inmem" to "keyvalue" (#1475)
* Copy existing inmem backend to keyvalue. Test with Artifact and IsOccurrence. Signed-off-by: Jeff Mendoza <[email protected]> * Update all of keyvalue backend to from old inmem to new kv interface. Signed-off-by: Jeff Mendoza <[email protected]> * Add changes from commit 165897d to keyvalue. Signed-off-by: Jeff Mendoza <[email protected]> * Add changes from commit fb58ab3 to keyvalue. Signed-off-by: Jeff Mendoza <[email protected]> * Remove inmem. Signed-off-by: Jeff Mendoza <[email protected]> --------- Signed-off-by: Jeff Mendoza <[email protected]>
- Loading branch information
1 parent
5521770
commit 030cf7f
Showing
70 changed files
with
6,651 additions
and
6,525 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
// | ||
// Copyright 2023 The GUAC Authors. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package stablememmap | ||
|
||
import ( | ||
"context" | ||
"slices" | ||
|
||
"github.com/guacsec/guac/pkg/assembler/kv" | ||
"github.com/guacsec/guac/pkg/assembler/kv/memmap" | ||
) | ||
|
||
type Store struct { | ||
mm kv.Store | ||
} | ||
|
||
func GetStore() kv.Store { | ||
return &Store{ | ||
mm: memmap.GetStore(), | ||
} | ||
} | ||
|
||
func (s *Store) Get(ctx context.Context, c, k string, v any) error { | ||
return s.mm.Get(ctx, c, k, v) | ||
} | ||
|
||
func (s *Store) Set(ctx context.Context, c, k string, v any) error { | ||
return s.mm.Set(ctx, c, k, v) | ||
} | ||
|
||
func (s *Store) Keys(ctx context.Context, c string) ([]string, error) { | ||
keys, err := s.mm.Keys(ctx, c) | ||
if err != nil { | ||
return nil, err | ||
} | ||
slices.Sort(keys) | ||
return keys, nil | ||
} |
Oops, something went wrong.