日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

netflix feign概述

發布時間:2025/4/5 编程问答 29 豆豆
生活随笔 收集整理的這篇文章主要介紹了 netflix feign概述 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

1.什么是feign?feign的作用是什么?

Feign is a java to http client binder inspired by Retrofit, JAXRS-2.0, and WebSocket. Feign's first goal was reducing the complexity of binding Denominator uniformly to http apis regardless of restfulness.

2.為什么使用feign?

You can use tools like Jersey and CXF to write java clients for ReST or SOAP services. You can write your own code on top of http transport libraries like Apache HC. Feign aims to connect your code to http apis with minimal overhead and code. Via customizable decoders and error handling, you should be able to write to any text-based http api.

3.feign工作機制

Feign works by processing annotations into a templatized request. Just before sending it off, arguments are applied to these templates in a straightforward fashion. While this limits Feign to only supporting text-based apis, it dramatically simplified system aspects such as replaying requests. It is also stupid easy to unit test your conversions knowing this.

4.主要類及其層次結構

?

?1.Feign's purpose is to ease development against http apis that feign restfulness. ?In?implementation, Feign is a {@link Feign#newInstance factory} for generating {@link Target?targeted} http apis.

重要方法:newInstance():Returns a new instance of an HTTP API, defined by annotations in the {@link Feign Contract},?for the specified {@code target}. You should cache this result.

2.Contract:?Defines what annotations and values are valid on interfaces.

3.Client:Submits HTTP {@link Request requests}. Implementations are expected to be thread-safe.

4.Retryer:Cloned for each invocation to {@link Client#execute(Request, feign.Request.Options)}.Implementations may keep state to determine if retry operations should continue or not.

5.Encoder

Encodes an object into an HTTP request body. Like {@code javax.websocket.Encoder}. {@code
Encoder} is used when a method parameter has no {@code @Param} annotation. For example:

@POST@Path("/")void create(User user);

Example implementation:?

public class GsonEncoder implements Encoder {private final Gson gson;public GsonEncoder(Gson gson) {this.gson = gson;}@Overridepublic void encode(Object object, Type bodyType, RequestTemplate template) {template.body(gson.toJson(object, bodyType));}}

Form encoding If any parameters are found in {@link
feign.MethodMetadata#formParams()}, they will be collected and passed to the Encoder as a map.

Ex. The following is a form. Notice the parameters aren't consumed in the request line. A map
including "username" and "password" keys will passed to the encoder, and the body type will be
{@link #MAP_STRING_WILDCARD}.

@RequestLine("POST /")Session login(@Param("username") String username, @Param("password") Stringpassword);

6.Decoder

Decodes an HTTP response into a single object of the given {@code type}. Invoked when {@link
Response#status()} is in the 2xx range and the return type is neither {@code void} nor {@code
Response}. Example Implementation:

public class GsonDecoder implements Decoder {private final Gson gson = new Gson();@Overridepublic Object decode(Response response, Type type) throws IOException {try {return gson.fromJson(response.body().asReader(), type);} catch (JsonIOException e) {if (e.getCause() != null &&e.getCause() instanceof IOException) {throw IOException.class.cast(e.getCause());}throw e;}}}

<h3>Implementation Note</h3> The {@code type} parameter will correspond to the {@link java.lang.reflect.Method#getGenericReturnType() generic return type} of an {@link feign.Target#type() interface} processed by {@link feign.Feign#newInstance(feign.Target)}. When writing your implementation of Decoder, ensure you also test parameterized types such as {@code List<Foo>}.
<h3>Note on exception propagation</h3> Exceptions thrown by {@link Decoder}s get wrapped in a {@link DecodeException} unless they are a subclass of {@link FeignException} already, and unless
the client was configured with {@link Feign.Builder#decode404()}.

7.?InvocationHandlerFactory:Controls reflective method dispatch

?

轉載于:https://www.cnblogs.com/davidwang456/p/6435311.html

總結

以上是生活随笔為你收集整理的netflix feign概述的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。

主站蜘蛛池模板: 在线观看免费看片 | 精品香蕉99久久久久网站 | 天天色天天射天天干 | 一级二级三级视频 | 久草综合网 | 香蕉久久精品 | 欧美日皮视频 | 欧美黄色一级大片 | 久久婷婷精品 | 骚虎视频在线观看 | 插入综合网| 久久伊人精品视频 | 女性向小h片资源在线观看 日本天天操 | 亚洲精品天天 | 久久97精品久久久久久久不卡 | 操伊人 | 波多野结衣在线电影 | 欧美日韩中文字幕在线播放 | 国产吞精囗交免费视频 | 波多野结衣av电影 | 精品黄色在线观看 | 草久视频在线观看 | 色婷婷色综合 | 午夜不卡久久精品无码免费 | 欧美亚洲中文精品字幕 | 国产黄网站 | 这里只有久久精品 | 亚洲一区在线免费观看 | 69国产成人精品二区 | 亚洲精品一区二区三区区别 | 国产网站黄色 | 91免费看国产 | 制服丝袜成人动漫 | 成人黄色网址在线观看 | 午夜在线影院 | 免费观看av网址 | 黑人精品xxx一区一二区 | 日本一区二区视频在线 | 欧洲毛片 | 狠狠人妻久久久久久综合蜜桃 | 亚洲在线一区二区 | 日本丰满熟妇bbxbbxhd | 国产伦精品一区二区三区千人斩 | 人人看人人爽 | 成年人小视频在线观看 | 超碰碰碰碰 | 伊人99re | 国产美女明星三级做爰 | 国模精品一区二区三区 | 中文字幕第28页 | 91国自啪 | 欧美色图一区二区三区 | 男人晚上看的视频 | 免费观看黄色网页 | 天天综合网在线观看 | 天堂av网址 | 99久久婷婷国产综合精品电影 | 无码人妻一区二区三区线 | 国产在线青青草 | 护士的小嫩嫩好紧好爽 | 精品人妻一区二区三区日产乱码卜 | 久久九九免费视频 | 右手影院亚洲欧美 | 91高清视频免费观看 | 婷婷丁香九月 | 96看片 | 麻豆视频国产精品 | 日本成人黄色片 | 激情xxxx| 操碰视频 | 国产午夜无码视频在线观看 | 永久免费精品视频 | 免费毛片软件 | 特黄aaaaaaaaa毛片免 | 高h喷汁呻吟3p | 久草综合在线视频 | 91视频综合 | 在线观看www. | 精品黑人一区二区三区在线观看 | 黄色资源在线 | 免费看一级一片 | 久青草影院 | 人人爱人人澡 | 开心激情网五月天 | 国产对白刺激视频 | 久久精品国产大片免费观看 | 亚洲中文字幕无码av | 被绑在床强摁做开腿呻吟 | 91二区 | 色噜噜在线观看 | 天堂网一区 | 91原创国产 | 无码日本精品xxxxxxxxx | 亚洲理论电影在线观看 | 亚洲精品国产成人无码 | 国产成人在线看 | 青青草一区二区三区 | 亚洲天堂一区二区在线观看 | 亚洲区一区二区三区 |