This repository has been archived by the owner on Mar 16, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 97
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Passivation configured in language supports via the discovery protocol (
#486)
- Loading branch information
1 parent
6d70778
commit 4904645
Showing
30 changed files
with
726 additions
and
51 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
32 changes: 32 additions & 0 deletions
32
java-support/src/main/java/io/cloudstate/javasupport/EntityOptions.java
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,32 @@ | ||
/* | ||
* Copyright 2019 Lightbend Inc. | ||
* | ||
* 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 io.cloudstate.javasupport; | ||
|
||
/** Options used for configuring an entity. */ | ||
public interface EntityOptions { | ||
|
||
/** @return the passivation strategy for an entity */ | ||
PassivationStrategy passivationStrategy(); | ||
|
||
/** | ||
* Create an entity option with the given passivation strategy. | ||
* | ||
* @param strategy to be used | ||
* @return the entity option | ||
*/ | ||
EntityOptions withPassivationStrategy(PassivationStrategy strategy); | ||
} |
45 changes: 45 additions & 0 deletions
45
java-support/src/main/java/io/cloudstate/javasupport/PassivationStrategy.java
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,45 @@ | ||
/* | ||
* Copyright 2019 Lightbend Inc. | ||
* | ||
* 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 io.cloudstate.javasupport; | ||
|
||
import io.cloudstate.javasupport.impl.Timeout; | ||
|
||
import java.time.Duration; | ||
|
||
/** A passivation strategy. */ | ||
public interface PassivationStrategy { | ||
|
||
/** | ||
* Create a passivation strategy that passivates the entity after the default duration (30 | ||
* seconds) of inactivity. | ||
* | ||
* @return the passivation strategy | ||
*/ | ||
static PassivationStrategy defaultTimeout() { | ||
return new Timeout(); | ||
} | ||
|
||
/** | ||
* Create a passivation strategy that passivates the entity after a given duration of inactivity. | ||
* | ||
* @param duration of inactivity after which the passivation should occur. | ||
* @return the passivation strategy | ||
*/ | ||
static PassivationStrategy timeout(Duration duration) { | ||
return new Timeout(duration); | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
java-support/src/main/java/io/cloudstate/javasupport/crdt/CrdtEntityOptions.java
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,36 @@ | ||
/* | ||
* Copyright 2019 Lightbend Inc. | ||
* | ||
* 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 io.cloudstate.javasupport.crdt; | ||
|
||
import io.cloudstate.javasupport.EntityOptions; | ||
import io.cloudstate.javasupport.PassivationStrategy; | ||
import io.cloudstate.javasupport.impl.crdt.CrdtEntityOptionsImpl; | ||
|
||
/** Root entity options for all CRDT. */ | ||
public interface CrdtEntityOptions extends EntityOptions { | ||
|
||
CrdtEntityOptions withPassivationStrategy(PassivationStrategy strategy); | ||
|
||
/** | ||
* Create a default CRDT entity option. | ||
* | ||
* @return the entity option | ||
*/ | ||
static CrdtEntityOptions defaults() { | ||
return new CrdtEntityOptionsImpl(PassivationStrategy.defaultTimeout()); | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
java-support/src/main/java/io/cloudstate/javasupport/entity/EntityOptions.java
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,35 @@ | ||
/* | ||
* Copyright 2019 Lightbend Inc. | ||
* | ||
* 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 io.cloudstate.javasupport.entity; | ||
|
||
import io.cloudstate.javasupport.PassivationStrategy; | ||
import io.cloudstate.javasupport.impl.entity.ValueEntityOptionsImpl; | ||
|
||
/** Root entity options for all value based entities. */ | ||
public interface EntityOptions extends io.cloudstate.javasupport.EntityOptions { | ||
|
||
EntityOptions withPassivationStrategy(PassivationStrategy strategy); | ||
|
||
/** | ||
* Create a default entity option for a value based entity. | ||
* | ||
* @return the entity option | ||
*/ | ||
static EntityOptions defaults() { | ||
return new ValueEntityOptionsImpl(PassivationStrategy.defaultTimeout()); | ||
} | ||
} |
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
Oops, something went wrong.