Comments (4)
I would see the proxy setting feature as a nice enhancement to the PostgresStarter class.
from postgresql-embedded.
@TheNitek thanks for suggestion. This project is based on embed.process library, which supports such ability. You should specify your own proxyConfig
within the DownloadConfigBuilder
, which is a propery of ArtifactStoreBuilder
. If you specify your own manually, you can set up the proxy configuration. Something like:
IRuntimeConfig runtimeConfig = new RuntimeConfigBuilder()
.defaults(Command.Postgres)
.artifactStore(new ArtifactStoreBuilder()
.defaults(Command.Postgres)
.download(new DownloadConfigBuilder()
.defaultsForCommand(Command.Postgres)
.proxyFactory(new HttpProxyFactory("www.proxy.com", 8000))
.build()
)
).build();
from postgresql-embedded.
@smecsia could you provide a running example? Would be cool if the environment variables could be used.
from postgresql-embedded.
Hi guys,
I've created a small Proxyfactory which is working nicely with our corporate proxy server.
It is evaluating the system environment variables -Dhttp.proxyHost, -Dhttp.proxyPort, -Dhttps.proxyHost, -Dhttps.proxyPort but is not supporting proxyservers which needs authentication.
If proxysettings for https and http are defined, https settings are preferred.
Maybe it's an inspiration for a default implementation.
Looks like the following:
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.Proxy;
import java.net.UnknownHostException;
import java.util.Objects;
import de.flapdoodle.embed.process.config.store.IProxyFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class HttpProxyFactory implements IProxyFactory {
private static final Logger LOGGER = LoggerFactory.getLogger(HttpProxyFactory.class);
@Override
public Proxy createProxy() {
ProxyConfiguration httpConfig = createProxyConfig("http");
ProxyConfiguration httpsConfig = createProxyConfig("https");
if (!httpConfig.isValid() && !httpsConfig.isValid()) {
return Proxy.NO_PROXY;
}
if (httpsConfig.isValid()) {
return configureProxy(httpsConfig);
}
return configureProxy(httpConfig);
}
private ProxyConfiguration createProxyConfig(String protocol) {
return new ProxyConfiguration(System.getProperty(protocol + ".proxyHost"),
System.getProperty(protocol + ".proxyPort"));
}
private Proxy configureProxy(ProxyConfiguration config) {
try {
Proxy proxy = new Proxy(Proxy.Type.HTTP,
new InetSocketAddress(InetAddress.getByName(config.getHost()), config.getPort()));
LOGGER.info("Using proxy " + config.getHost() + ":" + config.getPort());
return proxy;
} catch (UnknownHostException e) {
LOGGER.error("Creating proxy failed, falling back to no proxy", e);
return Proxy.NO_PROXY;
}
}
private static class ProxyConfiguration {
private final String host;
private final String port;
private ProxyConfiguration(String host, String port) {
this.host = host;
this.port = port;
}
private String getHost() {
return host;
}
private Integer getPort() {
return Integer.valueOf(port);
}
private boolean isValid() {
return Objects.nonNull(host) && Objects.nonNull(port) && port.matches("[0-9]{4,5}");
}
}
}
from postgresql-embedded.
Related Issues (20)
- Update de.flapdoodle.embed.process to 2.0.3 HOT 6
- Failed to read PID file HOT 7
- "Possibly failed to run initdb" - Windows HOT 5
- Configurable timeout when starting
- stop postgresql on shutdown not working
- ETA on 2.10 release? HOT 2
- Cached server path fails to find PID on Unix HOT 9
- postgresql-embedded fails to start in travis environment HOT 2
- Cannot install extensions anymore... HOT 1
- Postgres 11.1 for Linux HOT 5
- "restoreFromFile" executes more hour HOT 1
- java.lang.NoSuchFieldException: handle thrown possible because of JDK11 HOT 7
- Add start method which takes IRuntimeConfig without List<String> additionalParams
- How to run this on a buildserver through jenkins (postmaster.pid does not exist)? HOT 4
- JSON functions support
- Mac OS "No space left on device" on local tests
- Download via SSL possible?
- Download of DB broken with 403 HOT 1
- PgSQL version upgrade, Feb 14, 2019 releases
- Version.V11_1 Not Working HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from postgresql-embedded.