-
Notifications
You must be signed in to change notification settings - Fork 96
[Raft] Add Raft store stubs #1451
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
MariemBaccari
wants to merge
16
commits into
interuss:master
Choose a base branch
from
Orbitalize:add_raftstore_stubs
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
3f3b8ac
add raft store stubs
MariemBaccari d5b7fcc
Store methods should panic
MariemBaccari 93ccf26
fix lint
MariemBaccari 506ecf4
improve skipping
MariemBaccari 8de30ae
cleanup
MariemBaccari 07a8e8a
add RaftStoreType
MariemBaccari 46b6cf8
move struct definition
MariemBaccari c37535f
use err type and const for sql
MariemBaccari 3326aa8
use errcode
MariemBaccari 95c46f5
move to pkg/raftstore
MariemBaccari 51750f0
formatted string for flag def
MariemBaccari 6e86c0c
add raftstore dir
MariemBaccari f825201
add back comments
MariemBaccari 5d6b9ed
address max's comments
MariemBaccari 9fe813c
address Mike's comments
MariemBaccari 063810c
remove panics from store.go
MariemBaccari File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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,30 @@ | ||
| package raftstore | ||
|
|
||
| import ( | ||
| "context" | ||
|
|
||
| dsserr "github.com/interuss/dss/pkg/errors" | ||
| "github.com/interuss/stacktrace" | ||
| ) | ||
|
|
||
| type Store[R any] struct{} | ||
|
|
||
| func Init[R any]() *Store[R] { | ||
| return &Store[R]{} | ||
| } | ||
|
|
||
| // Transact proposes the entry to Raft and blocks until it is committed and applied. | ||
| func (s *Store[R]) Transact(ctx context.Context, f func(context.Context, R) error) error { | ||
| return stacktrace.NewErrorWithCode(dsserr.NotImplemented, "Transact not yet implemented for Raft store") | ||
| } | ||
|
|
||
| // Interact returns a repository that can be used to query the store without proposing a Raft entry. | ||
| func (s *Store[R]) Interact(_ context.Context) (R, error) { | ||
| var empty R | ||
| return empty, stacktrace.NewErrorWithCode(dsserr.NotImplemented, "Interact not yet implemented for Raft store") | ||
| } | ||
|
|
||
| // Close shuts down the consensus instance. | ||
| func (s *Store[R]) Close() error { | ||
| return stacktrace.NewErrorWithCode(dsserr.NotImplemented, "Close not yet implemented for Raft store") | ||
| } |
This file contains hidden or 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 hidden or 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,18 @@ | ||
| package raftstore | ||
|
|
||
| import ( | ||
| "context" | ||
|
|
||
| dsserr "github.com/interuss/dss/pkg/errors" | ||
| dssmodels "github.com/interuss/dss/pkg/models" | ||
| scdmodels "github.com/interuss/dss/pkg/scd/models" | ||
| "github.com/interuss/stacktrace" | ||
| ) | ||
|
|
||
| func (r *repo) GetUssAvailability(_ context.Context, id dssmodels.Manager) (*scdmodels.UssAvailabilityStatus, error) { | ||
| return nil, stacktrace.NewErrorWithCode(dsserr.NotImplemented, "GetUssAvailability not yet implemented in raft store") | ||
| } | ||
|
|
||
| func (r *repo) UpsertUssAvailability(_ context.Context, ussa *scdmodels.UssAvailabilityStatus) (*scdmodels.UssAvailabilityStatus, error) { | ||
| return nil, stacktrace.NewErrorWithCode(dsserr.NotImplemented, "UpsertUssAvailability not yet implemented in raft store") | ||
| } |
This file contains hidden or 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,26 @@ | ||
| package raftstore | ||
|
|
||
| import ( | ||
| "context" | ||
|
|
||
| dsserr "github.com/interuss/dss/pkg/errors" | ||
| dssmodels "github.com/interuss/dss/pkg/models" | ||
| scdmodels "github.com/interuss/dss/pkg/scd/models" | ||
| "github.com/interuss/stacktrace" | ||
| ) | ||
|
|
||
| func (r *repo) SearchConstraints(_ context.Context, v4d *dssmodels.Volume4D) ([]*scdmodels.Constraint, error) { | ||
| return nil, stacktrace.NewErrorWithCode(dsserr.NotImplemented, "SearchConstraints not yet implemented in raft store") | ||
| } | ||
|
|
||
| func (r *repo) GetConstraint(_ context.Context, id dssmodels.ID) (*scdmodels.Constraint, error) { | ||
| return nil, stacktrace.NewErrorWithCode(dsserr.NotImplemented, "GetConstraint not yet implemented in raft store") | ||
| } | ||
|
|
||
| func (r *repo) UpsertConstraint(_ context.Context, constraint *scdmodels.Constraint) (*scdmodels.Constraint, error) { | ||
| return nil, stacktrace.NewErrorWithCode(dsserr.NotImplemented, "UpsertConstraint not yet implemented in raft store") | ||
| } | ||
|
|
||
| func (r *repo) DeleteConstraint(_ context.Context, id dssmodels.ID) error { | ||
| return stacktrace.NewErrorWithCode(dsserr.NotImplemented, "DeleteConstraint not yet implemented in raft store") | ||
| } |
This file contains hidden or 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,3 @@ | ||
| // Package scd.store.raftstore provides a full implementation of store.Store[scd.repos.Repository] | ||
| // for Raft-based in-memory data storage. | ||
| package raftstore |
This file contains hidden or 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,35 @@ | ||
| package raftstore | ||
|
|
||
| import ( | ||
| "context" | ||
| "time" | ||
|
|
||
| dsserr "github.com/interuss/dss/pkg/errors" | ||
| dssmodels "github.com/interuss/dss/pkg/models" | ||
| scdmodels "github.com/interuss/dss/pkg/scd/models" | ||
| "github.com/interuss/stacktrace" | ||
| ) | ||
|
|
||
| func (r *repo) GetOperationalIntent(_ context.Context, id dssmodels.ID) (*scdmodels.OperationalIntent, error) { | ||
| return nil, stacktrace.NewErrorWithCode(dsserr.NotImplemented, "GetOperationalIntent not yet implemented in raft store") | ||
| } | ||
|
|
||
| func (r *repo) DeleteOperationalIntent(_ context.Context, id dssmodels.ID) error { | ||
| return stacktrace.NewErrorWithCode(dsserr.NotImplemented, "DeleteOperationalIntent not yet implemented in raft store") | ||
| } | ||
|
|
||
| func (r *repo) UpsertOperationalIntent(_ context.Context, operation *scdmodels.OperationalIntent) (*scdmodels.OperationalIntent, error) { | ||
| return nil, stacktrace.NewErrorWithCode(dsserr.NotImplemented, "UpsertOperationalIntent not yet implemented in raft store") | ||
| } | ||
|
|
||
| func (r *repo) SearchOperationalIntents(_ context.Context, v4d *dssmodels.Volume4D) ([]*scdmodels.OperationalIntent, error) { | ||
| return nil, stacktrace.NewErrorWithCode(dsserr.NotImplemented, "SearchOperationalIntents not yet implemented in raft store") | ||
| } | ||
|
|
||
| func (r *repo) GetDependentOperationalIntents(_ context.Context, subscriptionID dssmodels.ID) ([]dssmodels.ID, error) { | ||
| return nil, stacktrace.NewErrorWithCode(dsserr.NotImplemented, "GetDependentOperationalIntents not yet implemented in raft store") | ||
| } | ||
|
|
||
| func (r *repo) ListExpiredOperationalIntents(_ context.Context, threshold time.Time) ([]*scdmodels.OperationalIntent, error) { | ||
| return nil, stacktrace.NewErrorWithCode(dsserr.NotImplemented, "ListExpiredOperationalIntents not yet implemented in raft store") | ||
| } |
This file contains hidden or 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,13 @@ | ||
| package raftstore | ||
|
|
||
| import ( | ||
| "github.com/interuss/dss/pkg/raftstore" | ||
| "github.com/interuss/dss/pkg/scd/repos" | ||
| ) | ||
|
|
||
| // repo is a full implementation of scd.repos.Repository for Raft-based in-memory storage. | ||
| type repo struct{} | ||
|
|
||
| func Init() (*raftstore.Store[repos.Repository], error) { | ||
| return raftstore.Init[repos.Repository](), nil | ||
| } |
This file contains hidden or 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,40 @@ | ||
| package raftstore | ||
|
|
||
| import ( | ||
| "context" | ||
| "time" | ||
|
|
||
| "github.com/golang/geo/s2" | ||
| dsserr "github.com/interuss/dss/pkg/errors" | ||
| dssmodels "github.com/interuss/dss/pkg/models" | ||
| scdmodels "github.com/interuss/dss/pkg/scd/models" | ||
| "github.com/interuss/stacktrace" | ||
| ) | ||
|
|
||
| func (r *repo) SearchSubscriptions(_ context.Context, v4d *dssmodels.Volume4D) ([]*scdmodels.Subscription, error) { | ||
| return nil, stacktrace.NewErrorWithCode(dsserr.NotImplemented, "SearchSubscriptions not yet implemented in raft store") | ||
| } | ||
|
|
||
| func (r *repo) GetSubscription(_ context.Context, id dssmodels.ID) (*scdmodels.Subscription, error) { | ||
| return nil, stacktrace.NewErrorWithCode(dsserr.NotImplemented, "GetSubscription not yet implemented in raft store") | ||
| } | ||
|
|
||
| func (r *repo) UpsertSubscription(_ context.Context, sub *scdmodels.Subscription) (*scdmodels.Subscription, error) { | ||
| return nil, stacktrace.NewErrorWithCode(dsserr.NotImplemented, "UpsertSubscription not yet implemented in raft store") | ||
| } | ||
|
|
||
| func (r *repo) DeleteSubscription(_ context.Context, id dssmodels.ID) error { | ||
| return stacktrace.NewErrorWithCode(dsserr.NotImplemented, "DeleteSubscription not yet implemented in raft store") | ||
| } | ||
|
|
||
| func (r *repo) IncrementNotificationIndices(_ context.Context, subscriptionIds []dssmodels.ID) ([]int, error) { | ||
| return nil, stacktrace.NewErrorWithCode(dsserr.NotImplemented, "IncrementNotificationIndices not yet implemented in raft store") | ||
| } | ||
|
|
||
| func (r *repo) LockSubscriptionsOnCells(_ context.Context, cells s2.CellUnion, subscriptionIds []dssmodels.ID, startTime *time.Time, endTime *time.Time) error { | ||
| return stacktrace.NewErrorWithCode(dsserr.NotImplemented, "LockSubscriptionsOnCells not yet implemented in raft store") | ||
| } | ||
|
|
||
| func (r *repo) ListExpiredSubscriptions(_ context.Context, threshold time.Time) ([]*scdmodels.Subscription, error) { | ||
| return nil, stacktrace.NewErrorWithCode(dsserr.NotImplemented, "ListExpiredSubscriptions not yet implemented in raft store") | ||
| } |
This file contains hidden or 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 hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.