Skip to content

Commit

Permalink
Add the entity class for Xds flow control functionality
Browse files Browse the repository at this point in the history
Signed-off-by: hanbingleixue <[email protected]>
  • Loading branch information
hanbingleixue committed Nov 26, 2024
1 parent 7b2d7f8 commit b72bc93
Show file tree
Hide file tree
Showing 22 changed files with 1,126 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
* Copyright (C) 2024-2024 Sermant Authors. All rights reserved.
*
* 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.sermant.core.service.xds.entity;

/**
* FractionalPercent configuration information
*
* @author zhp
* @since 2024-11-18
*/
public class FractionalPercent {
/**
* The value of numerator
*/
private int numerator;

/**
* Specifies the denominator. If the denominator specified is less than the numerator, the final fractional
* percentage is capped at 1 (100%)
*/
private int denominator;

public int getNumerator() {
return numerator;
}

public void setNumerator(int numerator) {
this.numerator = numerator;
}

public int getDenominator() {
return denominator;
}

public void setDenominator(int denominator) {
this.denominator = denominator;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*
* Copyright (C) 2024-2024 Sermant Authors. All rights reserved.
*
* 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.sermant.core.service.xds.entity;

/**
* Xds Abort information
*
* @author zhp
* @since 2024-11-18
*/
public class XdsAbort {
/**
* HTTP status code to use to abort the HTTP request
*/
private int httpStatus;

/**
* The percentage of requests/ operations/ connections that will be aborted with the error code
*/
private float percentage;

public int getHttpStatus() {
return httpStatus;
}

public void setHttpStatus(int httpStatus) {
this.httpStatus = httpStatus;
}

public float getPercentage() {
return percentage;
}

public void setPercentage(float percentage) {
this.percentage = percentage;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* Copyright (C) 2024-2024 Sermant Authors. All rights reserved.
*
* 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.sermant.core.service.xds.entity;

/**
* Xds circuit breaker information
*
* @author zhp
* @since 2024-11-18
*/
public class XdsCircuitBreakers {
/**
* Maximum active request count
*/
private int maxRequests;

public int getMaxRequests() {
return maxRequests;
}

public void setMaxRequests(int maxRequests) {
this.maxRequests = maxRequests;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*
* Copyright (C) 2024-2024 Sermant Authors. All rights reserved.
*
* 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.sermant.core.service.xds.entity;

/**
* Xds Delay information
*
* @author zhp
* @since 2024-11-18
*/
public class XdsDelay {
/**
* the specified delay will be injected before a new request, in milliseconds.
*/
private long fixedDelay;

/**
* The percentage of requests on which the delay will be injected
*/
private float percentage;

public long getFixedDelay() {
return fixedDelay;
}

public void setFixedDelay(long fixedDelay) {
this.fixedDelay = fixedDelay;
}

public float getPercentage() {
return percentage;
}

public void setPercentage(float percentage) {
this.percentage = percentage;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*
* Copyright (C) 2024-2024 Sermant Authors. All rights reserved.
*
* 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.sermant.core.service.xds.entity;

/**
* Header name/ value pair
*
* @author zhp
* @since 2024-11-21
*/
public class XdsHeader {
/**
* Header name
*/
private String key;

/**
* Header value
*/
private String value;

public String getKey() {
return key;
}

public void setKey(String key) {
this.key = key;
}

public String getValue() {
return value;
}

public void setValue(String value) {
this.value = value;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*
* Copyright (C) 2024-2024 Sermant Authors. All rights reserved.
*
* 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.sermant.core.service.xds.entity;

/**
* Header name/ value pair plus option to control append behavior
*
* @author zhp
* @since 2024-11-21
*/
public class XdsHeaderOption {
/**
* Header name/ value pair that this option applies to
*/
private XdsHeader header;

/**
* Should the value be appended
*/
private boolean enabledAppend;

public XdsHeader getHeader() {
return header;
}

public void setHeader(XdsHeader header) {
this.header = header;
}

public boolean isEnabledAppend() {
return enabledAppend;
}

public void setEnabledAppend(boolean enabledAppend) {
this.enabledAppend = enabledAppend;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*
* Copyright (C) 2024-2024 Sermant Authors. All rights reserved.
*
* 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.sermant.core.service.xds.entity;

/**
* Xds fault information
*
* @author zhp
* @since 2024-11-18
*/
public class XdsHttpFault {
/**
* abort information, If specified, the filter will abort requests based on the values in the object
*/
private XdsAbort abort;

/**
* delay information, If specified, the filter will inject delays based on the values in the object
*/
private XdsDelay delay;

public XdsAbort getAbort() {
return abort;
}

public void setAbort(XdsAbort abort) {
this.abort = abort;
}

public XdsDelay getDelay() {
return delay;
}

public void setDelay(XdsDelay delay) {
this.delay = delay;
}
}
Loading

0 comments on commit b72bc93

Please sign in to comment.