Skip to content

Instantly share code, notes, and snippets.

View league55's full-sized avatar

Maksym Rudenko league55

  • Ukraine, Dnipro
View GitHub Profile
@league55
league55 / code_lint_diff.sh
Created December 19, 2019 09:36
Flake8 for python code linting. Script takes into account diff with develop branch.
PROJECT_DIR=$1
#now we need to act from a project source directory to have vsc in place
pushd ${PROJECT_DIR}
#we never push directly to develop and we want to run linter only on feature branches
#skip when on master branch as well
curr_branch_name=$(git rev-parse --abbrev-ref HEAD)
if [ "${curr_branch_name}" = "origin/develop" ] || [ "${curr_branch_name}" = "origin/master" ]; then
echo "Skipping linter for ${curr_branch_name}."
exit 0
@league55
league55 / code_lint.sh
Created December 19, 2019 09:34
Flake8 in a virtualenv
PROJECT_DIR=$1
# Creating temporary directory and new virtual environment not to mess things
TMP_DIR=$(mktemp -d)
virtualenv -p python3 ${TMP_DIR} >> /dev/null
source ${TMP_DIR}/bin/activate >> /dev/null
# installing flake
pip install flake8 >> /dev/null
flake8 ${PROJECT_DIR}
deactivate
rm -rf ${TMP_DIR}
DeploymentOptions options = new DeploymentOptions().setInstances(20);
vertx.deployVerticle(new IpProvider(dataProviderConf), options)
private void registerEventListener(String id) {
EventBus eventBus = vertx.eventBus();
logger.info("Registering new event handler " + id);
eventBus.consumer(id, message -> {
logger.info(String.valueOf(message.body()));
this.getInfo(String.valueOf(message.body()))
.setHandler(s -> {
message.reply(s.result());
s.succeeded();
@Override
public void start(Future<Void> future) throws Exception {
super.start();
NetServerOptions options = new NetServerOptions().setLogActivity(true);
NetServer server = vertx.createNetServer(options);
server.connectHandler(socket -> onInput(configuration, socket))
.listen(configuration.getPort(), configuration.getHost(), connectionStartedHandler(future, configuration));
}
@Override
public Future<String> getInfo(String input) {
logger.info("Providing for: " + input);
socket.write(input);
return Future.future(promise -> {
socket.handler(buffer -> {
promise.complete(buffer.getString(0, buffer.length()));
});
});
}
public class ServerConnection implements ConnectionService {
private Vertx vertx;
public ServerConnection(Vertx vertx) {
this.vertx = vertx;
}
@Override
public boolean enable(Connection configuration) {
vertx.createNetServer().connectHandler(socket -> onConnect(configuration, socket))