Skip to content
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

Refactor AI API policy gateway implementation #13706

Merged
merged 1 commit into from
Feb 26, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -555,5 +555,8 @@
"apim.governance.scheduler.thread_pool_size": "20",
"apim.governance.scheduler.queue_size": "20",
"apim.governance.scheduler.task_check_interval_minutes": "2",
"apim.governance.scheduler.task_cleanup_interval_minutes": "30"
"apim.governance.scheduler.task_cleanup_interval_minutes": "30",
"apim.ai.default_request_timeout": "30",
"apim.ai.failover_configurations.failover_endpoints_limit": "10",
"apim.ai.failover_configurations.default_request_timeout": "30"
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@

<sequence xmlns="http://ws.apache.org/ns/synapse" name="${endpointKey}_EndpointsSeq${deploymentStage}">
#if( $defaultEndpoint )
<filter xpath="$ctx:retryCount > 10">
<filter xpath="$ctx:retryCount > $retryCount">
<then>
#fail_scenario
</then>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
#end


#macro ( timeout $config)
#macro ( timeout $config $dynamicTimeout)
#if( $config.get("actionSelect") == "neverTimeout" )
## print nothing.
#elseif($config.get("actionDuration")|| $config.get("actionSelect"))
Expand All @@ -56,6 +56,9 @@
#elseif( $endpointClass != "ws" )
##add default timeout config for non WS endpoints
<timeout>
#if( $dynamicTimeout )
<duration>{get-property('REQUEST_TIMEOUT')}</duration>
#end
<responseAction>fault</responseAction>
</timeout>
#end
Expand Down Expand Up @@ -86,10 +89,10 @@
#end

##macro for http_endpoints in failover and load balance types
#macro ( http_endpoint $name $ep )
#macro ( http_endpoint $name $ep $dynamicTimeout)
<endpoint xmlns="http://ws.apache.org/ns/synapse" name="$name">
<http uri-template="$util.escapeXml($ep.get("url"))">
#timeout( $ep.get('config') )
#timeout( $ep.get('config') $dynamicTimeout)
#if($enableRetryCallWithNewOauthToken)
#set( $endpointSecurity = $endpoint_security.get($type) )
#if($endpointSecurity.type == "oauth" || $endpointSecurity.type == "OAUTH")
Expand Down Expand Up @@ -157,7 +160,7 @@
<endpoint xmlns="http://ws.apache.org/ns/synapse" name="${name}_${websocketResourceKey}">
<property name="OUT_ONLY" value="true"/>
<http uri-template="$util.escapeXml($endpointUrl)">
#timeout( $ep.get('config') )
#timeout( $ep.get('config') false)
</http>
<property name="ENDPOINT_ADDRESS" value="$util.escapeXml($endpointUrl)"/>
</endpoint>
Expand All @@ -175,7 +178,7 @@ format="$advance_ep.get("format")"
optimize="$advance_ep.get("optimize")"
#end
>
#timeout( $ep.get('config') )
#timeout( $ep.get('config') false)
</address>
<property name="ENDPOINT_ADDRESS" value="$util.escapeXml($ep.get("url"))"/>
</endpoint>
Expand Down Expand Up @@ -204,10 +207,9 @@ optimize="$advance_ep.get("optimize")"

#if($endpointUuid && "$endpointUuid" != "")
#set( $ep_key = "${endpointKey}_API_LLMEndpoint_${endpointUuid}" )
#end

#if( $endpointClass == "http" )
#http_endpoint( $ep_key $endpoints )
#http_endpoint( $ep_key $endpoints true)
#elseif( $endpointClass == "http" )
#http_endpoint( $ep_key $endpoints false)
#elseif( $endpointClass == "ws" )
#websocket_endpoint( $ep_key )
#elseif( $endpointClass == "address" )
Expand All @@ -219,14 +221,14 @@ optimize="$advance_ep.get("optimize")"
#if($endpoints.get("endpoint_type") == "address")
#address_endpoint("${ep_key}_0" $endpoints)
#else
#http_endpoint("${ep_key}_0" $endpoints)
#http_endpoint("${ep_key}_0" $endpoints false)
#end
#set( $i = 1)
#foreach($endpoint in $failover_endpoints)
#if($endpoint.get("endpoint_type") == "address")
#address_endpoint("${ep_key}_$i" $endpoint)
#else
#http_endpoint("${ep_key}_$i" $endpoint)
#http_endpoint("${ep_key}_$i" $endpoint false)
#end
#set( $i = $i + 1)
#end
Expand All @@ -250,7 +252,7 @@ optimize="$advance_ep.get("optimize")"
#if($endpoint.get("endpoint_type") == "address")
#address_endpoint("${ep_key}_$i" $endpoint)
#else
#http_endpoint("${ep_key}_$i" $endpoint)
#http_endpoint("${ep_key}_$i" $endpoint false)
#end
#set( $i = $i + 1)
#end
Expand All @@ -259,7 +261,7 @@ optimize="$advance_ep.get("optimize")"
#elseif ($endpointClass == "default")
<endpoint xmlns="http://ws.apache.org/ns/synapse" name="$ep_key">
<default>
#timeout( $endpoints.get('config') )
#timeout( $endpoints.get('config') false)
</default>
</endpoint>
#end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -555,5 +555,8 @@
"apim.governance.scheduler.thread_pool_size": "20",
"apim.governance.scheduler.queue_size": "20",
"apim.governance.scheduler.task_check_interval_minutes": "2",
"apim.governance.scheduler.task_cleanup_interval_minutes": "30"
"apim.governance.scheduler.task_cleanup_interval_minutes": "30",
"apim.ai.default_request_timeout": "30",
"apim.ai.failover_configurations.failover_endpoints_limit": "10",
"apim.ai.failover_configurations.default_request_timeout": "30"
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@

<sequence xmlns="http://ws.apache.org/ns/synapse" name="${endpointKey}_EndpointsSeq${deploymentStage}">
#if( $defaultEndpoint )
<filter xpath="$ctx:retryCount > 10">
<filter xpath="$ctx:retryCount > $retryCount">
<then>
#fail_scenario
</then>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
#end


#macro ( timeout $config)
#macro ( timeout $config $dynamicTimeout)
#if( $config.get("actionSelect") == "neverTimeout" )
## print nothing.
#elseif($config.get("actionDuration")|| $config.get("actionSelect"))
Expand All @@ -56,6 +56,9 @@
#elseif( $endpointClass != "ws" )
##add default timeout config for non WS endpoints
<timeout>
#if( $dynamicTimeout )
<duration>{get-property('REQUEST_TIMEOUT')}</duration>
#end
<responseAction>fault</responseAction>
</timeout>
#end
Expand Down Expand Up @@ -86,10 +89,10 @@
#end

##macro for http_endpoints in failover and load balance types
#macro ( http_endpoint $name $ep )
#macro ( http_endpoint $name $ep $dynamicTimeout )
<endpoint xmlns="http://ws.apache.org/ns/synapse" name="$name">
<http uri-template="$util.escapeXml($ep.get("url"))">
#timeout( $ep.get('config') )
#timeout( $ep.get('config') $dynamicTimeout)
#if($enableRetryCallWithNewOauthToken)
#set( $endpointSecurity = $endpoint_security.get($type) )
#if($endpointSecurity.type == "oauth" || $endpointSecurity.type == "OAUTH")
Expand Down Expand Up @@ -157,7 +160,7 @@
<endpoint xmlns="http://ws.apache.org/ns/synapse" name="${name}_${websocketResourceKey}">
<property name="OUT_ONLY" value="true"/>
<http uri-template="$util.escapeXml($endpointUrl)">
#timeout( $ep.get('config') )
#timeout( $ep.get('config') false)
</http>
<property name="ENDPOINT_ADDRESS" value="$util.escapeXml($endpointUrl)"/>
</endpoint>
Expand All @@ -175,7 +178,7 @@ format="$advance_ep.get("format")"
optimize="$advance_ep.get("optimize")"
#end
>
#timeout( $ep.get('config') )
#timeout( $ep.get('config') false)
</address>
<property name="ENDPOINT_ADDRESS" value="$util.escapeXml($ep.get("url"))"/>
</endpoint>
Expand Down Expand Up @@ -204,10 +207,9 @@ optimize="$advance_ep.get("optimize")"

#if($endpointUuid && "$endpointUuid" != "")
#set( $ep_key = "${endpointKey}_API_LLMEndpoint_${endpointUuid}" )
#end

#if( $endpointClass == "http" )
#http_endpoint( $ep_key $endpoints )
#http_endpoint( $ep_key $endpoints true)
#elseif( $endpointClass == "http" )
#http_endpoint( $ep_key $endpoints false)
#elseif( $endpointClass == "ws" )
#websocket_endpoint( $ep_key )
#elseif( $endpointClass == "address" )
Expand All @@ -219,14 +221,14 @@ optimize="$advance_ep.get("optimize")"
#if($endpoints.get("endpoint_type") == "address")
#address_endpoint("${ep_key}_0" $endpoints)
#else
#http_endpoint("${ep_key}_0" $endpoints)
#http_endpoint("${ep_key}_0" $endpoints false)
#end
#set( $i = 1)
#foreach($endpoint in $failover_endpoints)
#if($endpoint.get("endpoint_type") == "address")
#address_endpoint("${ep_key}_$i" $endpoint)
#else
#http_endpoint("${ep_key}_$i" $endpoint)
#http_endpoint("${ep_key}_$i" $endpoint false)
#end
#set( $i = $i + 1)
#end
Expand All @@ -250,7 +252,7 @@ optimize="$advance_ep.get("optimize")"
#if($endpoint.get("endpoint_type") == "address")
#address_endpoint("${ep_key}_$i" $endpoint)
#else
#http_endpoint("${ep_key}_$i" $endpoint)
#http_endpoint("${ep_key}_$i" $endpoint false)
#end
#set( $i = $i + 1)
#end
Expand All @@ -259,7 +261,7 @@ optimize="$advance_ep.get("optimize")"
#elseif ($endpointClass == "default")
<endpoint xmlns="http://ws.apache.org/ns/synapse" name="$ep_key">
<default>
#timeout( $endpoints.get('config') )
#timeout( $endpoints.get('config') false)
</default>
</endpoint>
#end
Expand Down

This file was deleted.

Loading
Loading