public static String createR2ClientLimiterKey ( Config config ) { String urlTemplate = config . getString ( HttpConstants . URL_TEMPLATE ) ; try { String escaped = URIUtil . encodeQuery ( urlTemplate ) ; URI uri = new URI ( escaped ) ; if ( uri . getHost ( ) == null ) throw new RuntimeException ( "Cannot get host part from uri" + urlTemplate ) ; String key = uri . getScheme ( ) + "/" + uri . getHost ( ) ; if ( uri . getPort ( ) > 0 ) { key = key + "/" + uri . getPort ( ) ; } log . info ( "Get limiter key [" + key + "]" ) ; return key ; } catch ( Exception e ) { throw new RuntimeException ( "Cannot create R2 limiter key" , e ) ; } }
Convert D2 URL template into a string used for throttling limiter