springcloud-cluster

    阅读全文
fightinggg's avatar
fightinggg 12月 16, 2020

springcloud-gateway

nexthexonextbutterflyvolantisyearnyiliashokaindigoapollolandscapecactusmateryicarusfluidmaterial Spring Cloud Gateway12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697package com.example.demo;import java.util.ArrayList;import java.util.List;import org.springframework.boot.SpringApplication;import org.springframework.boot.autoconfigure.SpringBootApplication;import org.springframework.cloud.gateway.event.RefreshRoutesEvent;import org.springframework.cloud.gateway.route.RouteDefinition;import org.springframework.cloud.gateway.route.RouteDefinitionRepository;import org.springframework.context.ApplicationEventPublisher;import org.springframework.context.ApplicationEventPublisherAware;import org.springframework.web.bind.annotation.DeleteMapping;import org.springframework.web.bind.annotation.GetMapping;import org.springframework.web.bind.annotation.PostMapping;import org.springframework.web.bind.annotation.PutMapping;import org.springframework.web.bind.annotation.RequestBody;import org.springframework.web.bind.annotation.RestController;import reactor.core.publisher.Flux;import reactor.core.publisher.Mono;// 动态路由// https://zhuanlan.zhihu.com/p/125018436@RestController@SpringBootApplicationpublic class DemoApplication implements RouteDefinitionRepository, ApplicationEventPublisherAware { public static void main(String[] args) { SpringApplication.run(DemoApplication.class, args); } // event publisher ApplicationEventPublisher applicationEventPublisher; @Override public void setApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher) { this.applicationEventPublisher = applicationEventPublisher; } // router List<RouteDefinition> memery = new ArrayList<>(); private void refreshRoute() { applicationEventPublisher.publishEvent(new RefreshRoutesEvent(this)); } @PutMapping Mono<Void> putRoute(@RequestBody Mono<RouteDefinition> o) { return o.flatMap(routeDefinition -> { memery.add(routeDefinition); refreshRoute(); return Mono.empty(); }); } @PostMapping Mono<Void> postRoute(@RequestBody Mono<RouteDefinition> o) { return o.flatMap(routeDefinition -> { for (int i = 0; i < memery.size(); i++) { if (memery.get(i).getId().equals(routeDefinition.getId())) { memery.set(i, routeDefinition); } } refreshRoute(); return Mono.empty(); }); } @DeleteMapping Mono<Void> deleteRoute(@RequestBody Mono<String> o) { return o.flatMap(id -> { memery.removeIf(routeDefinition -> routeDefinition.getId().equals(id)); refreshRoute(); return Mono.empty(); }); } @GetMapping Mono<List<RouteDefinition>> getRoute(){ return Mono.just(memery); } @Override public Flux<RouteDefinition> getRouteDefinitions() { return Flux.fromIterable(memery); } @Override public Mono<Void> save(Mono<RouteDefinition> route) { return Mono.empty(); } @Override public Mono<Void> delete(Mono<String> routeId) { return Mono.empty(); }}     阅读全文
fightinggg's avatar
fightinggg 11月 10, 2020

feign

    阅读全文
fightinggg's avatar
fightinggg 11月 01, 2020

SpringCloud5

    阅读全文
fightinggg's avatar
fightinggg 5月 01, 2020

SpringCloud4

    阅读全文
fightinggg's avatar
fightinggg 5月 01, 2020

SpringCloud3

nexthexonextbutterflyvolantisyearnyiliashokaindigoapollolandscapecactusmateryicarusfluidmaterial 入门资料中文文档官方文档中文文档社区嘿嘿     阅读全文
fightinggg's avatar
fightinggg 4月 29, 2020

SpringCloud2-微服务

nexthexonextbutterflyvolantisyearnyiliashokaindigoapollolandscapecactusmateryicarusfluidmaterial 微服务于微服务架构微服务强调服务的大小,他关注某一个点,一个模块只做一种事情微服务架构通常而言,他提倡将单一的程序划分为一组小的服务,每个服务运行在独立的进程中,采用轻量级的通信机制 doubbo是rpc,springcloud是restful     阅读全文
fightinggg's avatar
fightinggg 4月 29, 2020

SpringCloud1-入门

nexthexonextbutterflyvolantisyearnyiliashokaindigoapollolandscapecactusmateryicarusfluidmaterial 集群/分布式集群是多台计算机为了完成同一个工作,组合在一起达到更高的效率的系统 分布式是为了完成一个工作,将工作拆分为多个服务,分别运行在不同机器上的系统     阅读全文
fightinggg's avatar
fightinggg 4月 24, 2020