forked from ReactiveX/RxJava
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue ReactiveX#531: Added events to TimeLimiter (ReactiveX#583)
- Loading branch information
Showing
13 changed files
with
487 additions
and
33 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
dependencies { | ||
|
||
compile project(':resilience4j-core') | ||
} | ||
ext.moduleName='io.github.resilience4j.timelimiter' |
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
58 changes: 58 additions & 0 deletions
58
...iter/src/main/java/io/github/resilience4j/timelimiter/event/AbstractTimeLimiterEvent.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,58 @@ | ||
/* | ||
* | ||
* Copyright 2019 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 io.github.resilience4j.timelimiter.event; | ||
|
||
import java.time.ZonedDateTime; | ||
|
||
public abstract class AbstractTimeLimiterEvent implements TimeLimiterEvent { | ||
|
||
private final String timeLimiterName; | ||
private Type eventType; | ||
private final ZonedDateTime creationTime; | ||
|
||
AbstractTimeLimiterEvent(String timeLimiterName, Type eventType) { | ||
this.timeLimiterName = timeLimiterName; | ||
this.eventType = eventType; | ||
this.creationTime = ZonedDateTime.now(); | ||
} | ||
|
||
@Override | ||
public String getTimeLimiterName() { | ||
return timeLimiterName; | ||
} | ||
|
||
@Override | ||
public ZonedDateTime getCreationTime() { | ||
return creationTime; | ||
} | ||
|
||
@Override | ||
public Type getEventType() { | ||
return eventType; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "TimeLimiterEvent{" + | ||
"type=" + getEventType() + | ||
", timeLimiterName='" + getTimeLimiterName() + '\'' + | ||
", creationTime=" + getCreationTime() + | ||
'}'; | ||
} | ||
} |
50 changes: 50 additions & 0 deletions
50
...-timelimiter/src/main/java/io/github/resilience4j/timelimiter/event/TimeLimiterEvent.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,50 @@ | ||
/* | ||
* | ||
* Copyright 2019 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 io.github.resilience4j.timelimiter.event; | ||
|
||
import java.time.ZonedDateTime; | ||
|
||
/** | ||
* An event which is created by a {@link io.github.resilience4j.timelimiter.TimeLimiter}. | ||
*/ | ||
public interface TimeLimiterEvent { | ||
|
||
static TimeLimiterEvent of(String name, Type eventType) { | ||
switch (eventType) { | ||
case SUCCESS: | ||
return new TimeLimiterOnSuccessEvent(name); | ||
case TIMEOUT: | ||
return new TimeLimiterOnTimeoutEvent(name); | ||
default: | ||
return new TimeLimiterOnFailureEvent(name); | ||
} | ||
} | ||
|
||
String getTimeLimiterName(); | ||
|
||
Type getEventType(); | ||
|
||
ZonedDateTime getCreationTime(); | ||
|
||
enum Type { | ||
SUCCESS, | ||
TIMEOUT, | ||
FAILURE | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
...ter/src/main/java/io/github/resilience4j/timelimiter/event/TimeLimiterOnFailureEvent.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,27 @@ | ||
/* | ||
* | ||
* Copyright 2019 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 io.github.resilience4j.timelimiter.event; | ||
|
||
public class TimeLimiterOnFailureEvent extends AbstractTimeLimiterEvent { | ||
|
||
public TimeLimiterOnFailureEvent(String timeLimiterName) { | ||
super(timeLimiterName, Type.FAILURE); | ||
} | ||
|
||
} |
27 changes: 27 additions & 0 deletions
27
...ter/src/main/java/io/github/resilience4j/timelimiter/event/TimeLimiterOnSuccessEvent.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,27 @@ | ||
/* | ||
* | ||
* Copyright 2019 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 io.github.resilience4j.timelimiter.event; | ||
|
||
public class TimeLimiterOnSuccessEvent extends AbstractTimeLimiterEvent { | ||
|
||
public TimeLimiterOnSuccessEvent(String timeLimiterName) { | ||
super(timeLimiterName, Type.SUCCESS); | ||
} | ||
|
||
} |
27 changes: 27 additions & 0 deletions
27
...ter/src/main/java/io/github/resilience4j/timelimiter/event/TimeLimiterOnTimeoutEvent.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,27 @@ | ||
/* | ||
* | ||
* Copyright 2019 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 io.github.resilience4j.timelimiter.event; | ||
|
||
public class TimeLimiterOnTimeoutEvent extends AbstractTimeLimiterEvent { | ||
|
||
public TimeLimiterOnTimeoutEvent(String timeLimiterName) { | ||
super(timeLimiterName, Type.TIMEOUT); | ||
} | ||
|
||
} |
24 changes: 24 additions & 0 deletions
24
...ce4j-timelimiter/src/main/java/io/github/resilience4j/timelimiter/event/package-info.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,24 @@ | ||
/* | ||
* | ||
* Copyright 2019 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. | ||
* | ||
* | ||
*/ | ||
@NonNullApi | ||
@NonNullFields | ||
package io.github.resilience4j.timelimiter.event; | ||
|
||
import io.github.resilience4j.core.lang.NonNullApi; | ||
import io.github.resilience4j.core.lang.NonNullFields; |
Oops, something went wrong.