-
Notifications
You must be signed in to change notification settings - Fork 22
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
feat: Expire unpublished operations #807
Conversation
Codecov Report
@@ Coverage Diff @@
## main #807 +/- ##
==========================================
+ Coverage 89.51% 89.56% +0.05%
==========================================
Files 141 143 +2
Lines 12338 12502 +164
==========================================
+ Hits 11044 11198 +154
- Misses 799 807 +8
- Partials 495 497 +2
Continue to review full report at Codecov.
|
c06f6e7
to
ef7006e
Compare
@@ -67,7 +67,7 @@ func (v *Factory) Create(version string, casClient cas.Client, casResolver ctxco | |||
var orbTxnProcessorOpts []txnprocessor.Option | |||
|
|||
if sidetreeCfg.UpdateDocumentStoreEnabled { | |||
updateDocumentStore, err := unpublished.New(provider) | |||
updateDocumentStore, _, err := unpublished.New(provider) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We do this same call in start.go
and I start the expiry service there, which is why I ignore the expiry service returned here. This object is the same as the one we make in start.go
. If possible, we should probably pass the unpublished operation store object from start.go
through to here instead of creating it twice.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was thinking that there should be a single expiry service and that multiple stores can register with it to expire their data.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I expected the same.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done! Take a look at the new design and let me know how it looks.
(Also, my note about passing the unpublished operation store object still stands)
ef7006e
to
eef774d
Compare
scripts/integration.sh
Outdated
go test -run all -count=1 -v -cover . -p 1 -timeout=20m -race | ||
#export CAS_TYPE=ipfs | ||
# | ||
#go test -run all -count=1 -v -cover . -p 1 -timeout=20m -race |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you disabled ipfs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, we should have BDD test (can be done as separate PR)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops - I re-enabled IPFS tests. I've added a TODO for the BDD test - I'll do it in another PR
dba5ab2
to
683212f
Compare
cmd/orb-server/startcmd/start.go
Outdated
// TODO (#808): Allow expiry interval to be configurable. | ||
expiryService = expiry.NewService(defaultExpiryInterval) | ||
|
||
updateDocumentStore.RegisterWithExpiryService(expiryService) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this can be hidden by adding the expiry service to the list of providers and then unpublishedstore.New can Register.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The problem is that unpublishedstore.New is called in two places - here and in factory.go
, and we don't want to register it twice. What I think would be better is if the unpublished store instance from start.go
was passed into factory.go
, and that way I could safely add the Register call inside of unpublishedstore.New
since I will know that it's only called in one place. However, I see that factory
is an interface, so it would have to be changed (or I would have to add it to the config.Sidetree
object). Are there any issues with doing this? @sandrask
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should ignore (do not add) duplicate registrations - same store can be used in different places.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sandrask I could do that... but then I'll need to pass the expiry service into the factory, which we shouldn't do since factory really shouldn't need to know anything about the expiry
service. I think the cleanest solution is to create the unpublished store object once in start.go
and pass it around where needed, if possible.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure you can do that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
cmd/orb-server/startcmd/start.go
Outdated
// a separate server) | ||
|
||
// TODO (#808): Allow expiry interval to be configurable. | ||
expiryService = expiry.NewService(defaultExpiryInterval) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The expiry service can be created outside of this IF. Practically speaking, we will have these features enabled in production.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I create it outside of this if
statement, and updateDocumentStoreEnabled
is false, then I will have a pointless expiry service with no registered stores that will still start and still use a go routine. I will still need some mechanism to detect whether to start the expiry service or not. I could add a method to the expiry service so that the caller can check whether there are any registered stores so they can decide whether to start it, but I don't think that's simpler than what I already have. Also note that when there are more stores that need the expiry service, this problem will probably go away since I'll need to move it outside of the if
statement anyway.
You mentioned, however, that practically we will have the update document store enabled for production? If that's the case, do we need that option at all? If we can remove it, that will also make the issue go away and make the code simpler (factory.go
also checks that option). CC @sandrask
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you don't have any registrations don't start the service.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would have service running anyway in case that some store registers after start-up. Is this possible?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sandrask I don't think we will have store registers after start-up... at least not now. I was thinking that I would handle that scenario when/if we need that ability.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@DRK3 @bstasyszyn We can discuss if we need update document store enabled as an option. I always envisioned that we will have clients who will want to 'anchor' operation before using it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've left the option there per the discussion @sandrask @bstasyszyn. I've left the expiry service within the if
for now - in the future when I add other stores to this service, I'll need to revisit this though.
683212f
to
0a2545e
Compare
Signed-off-by: Derek Trider <Derek.Trider@securekey.com>
0a2545e
to
474bdd5
Compare
Signed-off-by: Derek Trider Derek.Trider@securekey.com