This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public function up() | |
{ | |
Schema::table('jobs', function (Blueprint $table) { | |
$table->dropIndex('jobs_queue_reserved_reserved_at_index'); | |
$table->dropColumn('reserved'); | |
$table->index(['queue', 'reserved_at']); | |
}); | |
Schema::table('failed_jobs', function (Blueprint $table) { | |
$table->longText('exception')->after('payload'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ... | |
# https://github.com/exAspArk/batch-loader | |
gem 'batch-loader' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Use a standard Node image from Docker Hub | |
FROM node:boron | |
# The Dockerfile's author | |
LABEL Usama Ashraf | |
# Create a directory in the container where the code will be placed | |
RUN mkdir -p /backend-dir-inside-container | |
# Set this as the default, working directory. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# docker-compose.yml | |
version: "3.2" | |
services: | |
rabbitmq-server: | |
build: ./rabbitmq-server | |
python-service: | |
build: ./python-service | |
# 'rabbitmq-server' will be available as a network reference inside this service |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# main.py | |
from flask import Flask | |
from flask import request | |
from flask import jsonify | |
from services.user_event_handler import emit_user_profile_update | |
app = Flask(__name__) | |
@app.route('/users/<int:user_id>', methods=['POST']) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# services/user_event_handler.py | |
import pika | |
import json | |
def emit_user_profile_update(user_id, new_data): | |
# 'rabbitmq-server' is the network reference we have to the broker, | |
# thanks to Docker Compose. | |
connection = pika.BlockingConnection(pika.ConnectionParameters(host='rabbitmq-server')) | |
channel = connection.channel() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// main.go | |
package main | |
import ( | |
"fmt" | |
"log" | |
"github.com/streadway/amqp" | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# app/middleware/service_worker_manager.rb | |
class ServiceWorkerManager | |
# We’ll pass 'service_workers' when we register this middleware. | |
def initialize(app, service_workers) | |
@app = app | |
@service_workers = service_workers | |
end | |
def call(env) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# config/environments/development.rb | |
# … | |
# Add our own middleware before the ActionDispatch::Static | |
# middleware and pass it an array of service worker URIs as a | |
# parameter. | |
config.middleware.insert_before ActionDispatch::Static, ServiceWorkerManager, ['service-worker.js'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// service-worker.js | |
// Changing the cache version will cause existing cached resources to be | |
// deleted the next time the service worker is re-installed and re-activated. | |
const CACHE_VERSION = 1; | |
const CURRENT_CACHE = `your-app-name-cache-v-${CACHE_VERSION}`; | |
const OFFLINE_PAGE_URL = 'offline/offline.html'; | |
const ASSETS_TO_BE_CACHED = ['offline/offline.css', 'offline/offline.jpg', OFFLINE_PAGE_URL]; | |
self.addEventListener('install', event => { |
OlderNewer