This file contains hidden or 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
| package device.packet; | |
| import device.packet.decoder.PacketDataDecoder; | |
| import static device.packet.response.DeviceResponse.success; | |
| public abstract class AbstractPacket implements Packet { | |
| public static final int SERIAL_NUMBER_INDEX = 5; |
This file contains hidden or 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
| import sinon from 'sinon'; | |
| import {expect} from 'chai'; | |
| import CircuitBreaker from '../../lib/support/CircuitBreaker'; | |
| describe('CircuitBreaker', () => { | |
| const sandbox = sinon.sandbox.create(); | |
| afterEach(() => { | |
| sandbox.restore(); | |
| }); |
This file contains hidden or 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
| import CircuitBreaker from 'circuit-breaker-js'; | |
| import logger from './logger'; | |
| function is5xxError(statusCode) { | |
| return statusCode >= 500 && statusCode < 600; | |
| } | |
| const defaultConfig = { | |
| volumeThreshold: 5, // error count | |
| errorThreshold: 50, // error percentage | |
| windowDuration: 10000, // milliseconds |
This file contains hidden or 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
| export function retry (func, recoverFunc) { | |
| return func() | |
| .catch( err => { | |
| logger.info(`Calling function failed with error, retrying once after recovery`, err); | |
| return recoverFunc(err).then(() => func()); | |
| }); | |
| } | |
| const executeRequest = () => { | |
| }; |
This file contains hidden or 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
| package com.qantas.stme.tests.mock.ifly; | |
| import com.qantas.stme.tests.mock.MockService; | |
| import org.apache.commons.io.IOUtils; | |
| import org.cryptacular.io.ClassPathResource; | |
| import org.mockserver.client.server.MockServerClient; | |
| import org.mockserver.model.Header; | |
| import org.mockserver.model.HttpResponse; | |
| import java.io.IOException; |
This file contains hidden or 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
| import { createMessageProcessor } from './sqsMessageProcessor'; | |
| import logger from '../../logger'; | |
| import config from '../../config'; | |
| import clsContext from '../../util/cls'; | |
| export function createHandler() { | |
| return (messageBody, done) => { | |
| logger.info('message received', messageBody); | |
| return doSomethingWithMessage(messageBody.data) | |
| .then(() => done()) | |
| .catch((error) => { |
This file contains hidden or 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
| import AWS from 'aws-sdk'; | |
| import SqsConsumer from 'sqs-consumer'; | |
| import uuid from 'uuid'; | |
| const MAX_VISIBILITY_TIMEOUT = 60 * 60 * 12 - 1; | |
| export const calculateNewTimeout = ({ visibilityTimeout, visibilityQuotient }, approximateReceivedCount) => { | |
| const newVisibilityTimeout = visibilityTimeout * (Math.pow(visibilityQuotient, approximateReceivedCount - 1) || 1); | |
| return Math.min(newVisibilityTimeout, MAX_VISIBILITY_TIMEOUT); | |
| }; | |
| const createProcessingErrorHandler = ({ sqs, sqsUrl, config, logger }) => (error, message) => { | |
| const visibilityParams = { |