apollo

restTemplate 工具类

怎甘沉沦 提交于 2019-11-29 08:05:11
比自己封装的http工具靠谱,毕竟feign和ribbon也用这个,没有那么多需要考虑的地方,apollo也基于restTemplate封装了一个工具类。默认用的是HttpURLConnection。和okhttp比起来也差不了多少,本人在本地测了一下 import org.springframework.http.*; import org.springframework.util.CollectionUtils; import org.springframework.util.MultiValueMap; import org.springframework.web.client.RestTemplate; import java.util.Map; /** * @author liyhu * @date 2019年09月06日 */ public class RestTemplateUtil { /** * 实际执行请求的template */ private static RestTemplate restTemplate=new RestTemplate(); /** * json请求 * @param url * @param entity * @param cls * @param <T> * @return */ public static <T>T post

How to run a mutation on mount with React Apollo 2.1's Mutation component?

只愿长相守 提交于 2019-11-29 07:34:44
问题 We are currently moving from Relay to React Apollo 2.1 and something I'm doing seems fishy. Context: Some components must only be rendered if the user is authenticated (via an API key), so there is an Authenticator component guarding the rest of the tree. In App.js , it gets used like this (obviously all snippets below are minimal examples): import React from 'react'; import Authenticator from './Authenticator'; import MyComponent from './MyComponent'; export default function App({ apiKey })

How to execute an async fetch request and then retry last failed request?

左心房为你撑大大i 提交于 2019-11-28 23:00:19
问题 Apollo link offers an error handler onError Issue: Currently, we wish to refresh oauth tokens when they expires during an apollo call and we are unable to execute an async fetch request inside the onError properly. Code: initApolloClient.js import { ApolloClient } from 'apollo-client'; import { onError } from 'apollo-link-error'; import { ApolloLink, fromPromise } from 'apollo-link'; //Define Http link const httpLink = new createHttpLink({ uri: '/my-graphql-endpoint', credentials: 'include' }

Apollo配置中心架构剖析以及对比分析

不想你离开。 提交于 2019-11-28 22:41:51
Apollo 官网: Github 简介 Apollo(阿波罗)是携程框架部门研发的分布式配置中心,能够集中化管理应用不同环境、不同集群的配置,配置修改后能够实时推送到应用端,并且具备规范的权限、流程治理等特性,适用于微服务配置管理场景。 服务端基于Spring Boot和Spring Cloud开发,打包后可以直接运行,不需要额外安装Tomcat等应用容器。 Java客户端不依赖任何框架,能够运行于所有Java运行时环境,同时对Spring/Spring Boot环境也有较好的支持。 .Net客户端不依赖任何框架,能够运行于所有.Net运行时环境。 核心概念 Apollo支持4个维度管理Key-Value格式的配置: application (应用): 这个很好理解,就是实际使用配置的应用,Apollo客户端在运行时需要知道当前应用是谁,从而可以去获取对应的配置 每个应用都需要有唯一的身份标识 – appId,我们认为应用身份是跟着代码走的,所以需要在代码中配置。 environment (环境): 配置对应的环境,Apollo客户端在运行时需要知道当前应用处于哪个环境,从而可以去获取应用的配置 我们认为环境和代码无关,同一份代码部署在不同的环境就应该能够获取到不同环境的配置 所以环境默认是通过读取机器上的配置(server.properties中的env属性)指定的

分布式配置中心Apollo——QuickStart

本小妞迷上赌 提交于 2019-11-28 20:59:21
分布式配置中心 剥离配置文件,实现动态修改,自动更新。 【假设没有分布式配置中心,修改配置文件后都需要重启服务,对于数量庞多的微服务开发来说,就会非常繁琐】 分布式配置中心有哪些 disconf(依赖zookeeper) zookeeper diamond (阿里巴巴) Apollo Redis xxl-job 为什么选择Apollo Apollo除了功能完备之外,在国内的普及度也相当广泛,也就意味着国内Apollo的生态非常活跃。虽然中国式过马路的行为并不提倡,但群众的眼睛有时还是雪亮的。 实战 环境准备: 阿里云CentOS7.6 jdk1.8 安装jdk1.8 yum search jdk yum install java-1.8.0-openjdk.x86_64(可选) java -version 安装MySQL 配置yum源 wget http://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm yum localinstall mysql57-community-release-el7-8.noarch.rpm 安装mysql yum install mysql-community-server 启动mysql systemctl start mysqld systemctl restart

Apollo配置详细步骤(Windows环境)

孤街醉人 提交于 2019-11-28 18:04:41
一. 准备工作 1.下载 apollo 安装包 下载链接: http://activemq.apache.org/apollo/download.html 2.下载 java JDK 安装包 ( apollo 依赖 java 环境) 下载链接: http://www.oracle.com/technetwork/java/javase/downloads/index.html 3.安装 java JDK 4.解压 apollo 安装包(免安装,自己选择路径,我这里解压在D盘) 注:如果你的操作系统是 Windows Vista, Server 2008 或更高版本,则需要安装MS VC++ 2010 Redistributable package(或更高版本补丁) 32位 下载链接: http://www.microsoft.com/en-us/download/details.aspx?id=5555 64位 下载链接: http://www.microsoft.com/en-us/download/details.aspx?id=14632 二. 环境变量的配置(当前测试机系统为 windows 8.1 英文版) 1. 配置 JAVA_HOME a. 桌面 -> 我的电脑 -> 右键 -> 属性 b. 高级系统设置 c. 高级 -> 环境变量 d. 新建系统变量 注: 测试

使用Apollo动态修改线上数据源

为君一笑 提交于 2019-11-28 17:01:31
前言    最近需要实现一个功能,动态刷新线上数据源环境,下面来使用Apollo配置中心和Spring提供的AbstractRoutingDataSource来实现。 具体实现    Apollo是携程开源的统一配置中心,和springboot无缝衔接并且不需要安装其他软件就可以直接使用,可以实时推送最新的配置文件。Spring提供的AbstractRoutingDataSource用于动态管理数据源,可以动态更新数据源,一般数据库的读写分离也是用这个抽象类实现的。   对Apollo不熟悉的可以先了解一下,GitHub:https://github.com/ctripcorp/apollo   关于AbstractRoutingDataSource,介绍一下我们用到的方法 public abstract class AbstractRoutingDataSource extends AbstractDataSource implements InitializingBean { //传入的数据源 private Map<Object, Object> targetDataSources; //拿着子类实现的determineCurrentLookupKey()方法的返回值当做key在这个Map中寻找数据源 private Map<Object, DataSource>

Sentinel Dashboard同步Apollo存储规则

本小妞迷上赌 提交于 2019-11-28 15:09:43
在之前的两篇教程中我们分别介绍了如何将Sentinel的限流规则存储到Nacos和Apollo中。同时,在文末的思考中,我都指出了这两套整合方案都存在一个不足之处:不论采用什么配置中心,限流规则都只能通过Nacos界面或Apollo界面来完成修改才能得到持久化存储,而在Sentinel Dashboard中修改限流规则虽然可以生效,但是不会被持久化到配置中心。而在这两个配置中心里存储的数据是一个Json格式,当存储的规则越来越多,对该Json配置的可读性与可维护性会变的越来越差。所以,下面我们就来继续探讨这个不足之处,并给出相应的解决方案。本文以Apollo存储为例,下一篇介绍Nacos的改在示例。 问题分析 在实际操作之前,我们先通过下图了解一下之前我们所实现的限流规则持久化方案的配置数据流向图: 蓝色箭头 代表了限流规则由 配置中心 发起修改的更新路径 橙色箭头 代表了限流规则由 Sentinel Dashboard 发起修改的更新路径 从图中可以很明显的看到, Sentinel Dashboard 与业务服务之间本身是可以互通获取最新限流规则的,这在没有整合配置中心来存储限流规则的时候就已经存在这样的机制。最主要的区别是:配置中心的修改都可以实时的刷新到业务服务,从而被 Sentinel Dashboard 读取到,但是对于这些规则的更新到达各个业务服务之后

搭建mqtt服务器apollo

醉酒当歌 提交于 2019-11-28 13:34:26
使用的apollo,官网太慢,附上百度云下载地址: 链接:https://pan.baidu.com/s/1NIq6R71hlyPuaUBwPoMPNg 提取码:36vw 原文链接:https://blog.csdn.net/yangsong4353/article/details/87967561 需要注意的是想要在宿主机上访问,需要修改 Apollo监控页面配置   vi /opt/apollo/mybroker/etc/apollo.xml   修改   http://127.0.0.1:61680“/>   https://127.0.0.1:61681“/>   为   http://0.0.0.0:61680“/>   https://0.0.0.0:61681“/> MQTT服务器尝试过两种,一种是 Mosquitto、另一种是 Apollo,本次记录Apollo 在CentOS 7.6 linux 下的安装和测试。 Apollo下载地址: http://activemq.apache.org/apollo/versions/1.7/website/download.html 下载后的文件放置在Downloads文件夹下,对此压缩包进行解压。 有可能需要进入root权限,输入su,之后输入密码,进入root权限。 解压: tar -zxvf apache-apollo

Apollo/GraphQL field type for object with dynamic keys

怎甘沉沦 提交于 2019-11-28 10:04:01
Let's say my graphql server wants to fetch the following data as JSON where person3 and person5 are some id's: "persons": { "person3": { "id": "person3", "name": "Mike" }, "person5": { "id": "person5", "name": "Lisa" } } Question : How to create the schema type definition with apollo? The keys person3 and person5 here are dynamically generated depending on my query (i.e. the area used in the query). So at another time I might get person1 , person2 , person3 returned. As you see persons is not an Iterable, so the following won't work as a graphql type definition I did with apollo: type Person {