-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add AttributeAccessor & Add total timeout control to Resilience4j
- Loading branch information
1 parent
b317123
commit 9cf88ee
Showing
22 changed files
with
181 additions
and
110 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
47 changes: 47 additions & 0 deletions
47
...ylive-bootstrap-api/src/main/java/com/jd/live/agent/bootstrap/util/AttributeAccessor.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,47 @@ | ||
/* | ||
* Copyright © ${year} ${owner} (${email}) | ||
* | ||
* 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 com.jd.live.agent.bootstrap.util; | ||
|
||
public interface AttributeAccessor { | ||
|
||
/** | ||
* Retrieves an attribute by key. | ||
* | ||
* @param key The key of the attribute to retrieve. | ||
* @return The value of the attribute, or null if not found. | ||
*/ | ||
<T> T getAttribute(String key); | ||
|
||
/** | ||
* Sets or replaces an attribute with the specified key and value. | ||
* | ||
* @param key The key of the attribute. | ||
* @param value The value of the attribute. | ||
*/ | ||
void setAttribute(String key, Object value); | ||
|
||
/** | ||
* Removes an attribute by its key. | ||
* | ||
* @param key The key of the attribute to remove. | ||
* @return The removed attribute, or null if the attribute was not found. | ||
*/ | ||
<T> T removeAttribute(String key); | ||
|
||
boolean hasAttribute(String key); | ||
|
||
String[] attributeNames(); | ||
} |
82 changes: 82 additions & 0 deletions
82
...ootstrap-api/src/main/java/com/jd/live/agent/bootstrap/util/AttributeAccessorSupport.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,82 @@ | ||
/* | ||
* Copyright © ${year} ${owner} (${email}) | ||
* | ||
* 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 com.jd.live.agent.bootstrap.util; | ||
|
||
import java.io.Serializable; | ||
import java.util.LinkedHashMap; | ||
import java.util.Map; | ||
|
||
public abstract class AttributeAccessorSupport implements AttributeAccessor, Serializable { | ||
|
||
private Map<String, Object> attributes; | ||
|
||
public AttributeAccessorSupport() { | ||
} | ||
|
||
public void setAttribute(String key, Object value) { | ||
if (key != null && value != null) { | ||
if (attributes == null) { | ||
attributes = new LinkedHashMap<>(); | ||
} | ||
attributes.put(key, value); | ||
} | ||
} | ||
|
||
public <T> T getAttribute(String key) { | ||
return key == null || attributes == null ? null : (T) attributes.get(key); | ||
} | ||
|
||
public <T> T removeAttribute(String key) { | ||
if (key != null && attributes != null) { | ||
return (T) attributes.remove(key); | ||
} | ||
return null; | ||
} | ||
|
||
public boolean hasAttribute(String key) { | ||
return this.attributes.containsKey(key); | ||
} | ||
|
||
public String[] attributeNames() { | ||
return this.attributes.keySet().toArray(new String[0]); | ||
} | ||
|
||
protected void copyAttributesFrom(AttributeAccessor source) { | ||
String[] attributeNames = source.attributeNames(); | ||
String[] var3 = attributeNames; | ||
int var4 = attributeNames.length; | ||
|
||
for (int var5 = 0; var5 < var4; ++var5) { | ||
String attributeName = var3[var5]; | ||
this.setAttribute(attributeName, source.getAttribute(attributeName)); | ||
} | ||
} | ||
|
||
public boolean equals(Object other) { | ||
if (this == other) { | ||
return true; | ||
} else if (!(other instanceof AttributeAccessorSupport)) { | ||
return false; | ||
} else { | ||
AttributeAccessorSupport that = (AttributeAccessorSupport) other; | ||
return this.attributes.equals(that.attributes); | ||
} | ||
} | ||
|
||
public int hashCode() { | ||
return this.attributes.hashCode(); | ||
} | ||
} |
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 |
---|---|---|
|
@@ -27,6 +27,8 @@ | |
*/ | ||
public interface Retrier { | ||
|
||
String DEADLINE_KEY = "deadline"; | ||
|
||
/** | ||
* Execute retry logic | ||
* | ||
|
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
Oops, something went wrong.