@ovotech/castle
Advanced tools
Comparing version 0.6.3 to 0.6.4
@@ -15,7 +15,8 @@ "use strict"; | ||
}; | ||
exports.produce = (config) => { | ||
const produce = (config) => { | ||
config; | ||
return (producer, messages) => producer.send({ ...config, messages }); | ||
}; | ||
exports.toFinalCastleConsumerConfig = (config) => { | ||
exports.produce = produce; | ||
const toFinalCastleConsumerConfig = (config) => { | ||
if ('eachSizedBatch' in config) { | ||
@@ -29,13 +30,19 @@ const { eachSizedBatch, maxBatchSize, ...rest } = config; | ||
}; | ||
exports.toFinalCastleConsumerConfig = toFinalCastleConsumerConfig; | ||
const isCastleConsumerConfig = (config) => Boolean(config.topic); | ||
exports.optionalConsumers = (configs) => configs.filter(isCastleConsumerConfig); | ||
exports.consumeEachMessage = (config) => config; | ||
const optionalConsumers = (configs) => configs.filter(isCastleConsumerConfig); | ||
exports.optionalConsumers = optionalConsumers; | ||
const consumeEachMessage = (config) => config; | ||
exports.consumeEachMessage = consumeEachMessage; | ||
// eslint-disable-next-line @typescript-eslint/ban-types | ||
exports.consumeEachBatch = (config) => config; | ||
exports.createKafka = (config) => { | ||
const consumeEachBatch = (config) => config; | ||
exports.consumeEachBatch = consumeEachBatch; | ||
const createKafka = (config) => { | ||
const schemaRegistry = new avro_kafkajs_1.SchemaRegistry(config.schemaRegistry); | ||
return new avro_kafkajs_1.AvroKafka(schemaRegistry, new kafkajs_1.Kafka(config.kafka), config.topicsAlias); | ||
}; | ||
exports.createProducer = (kafka, config) => kafka.producer(config); | ||
exports.createConsumers = (kafka, config) => config.map((consumerConfig) => { | ||
exports.createKafka = createKafka; | ||
const createProducer = (kafka, config) => kafka.producer(config); | ||
exports.createProducer = createProducer; | ||
const createConsumers = (kafka, config) => config.map((consumerConfig) => { | ||
const finalConfig = exports.toFinalCastleConsumerConfig(consumerConfig); | ||
@@ -45,3 +52,4 @@ const instance = kafka.consumer(finalConfig); | ||
}); | ||
exports.toCastleParts = (config) => { | ||
exports.createConsumers = createConsumers; | ||
const toCastleParts = (config) => { | ||
var _a; | ||
@@ -55,3 +63,4 @@ const kafka = exports.createKafka(config); | ||
}; | ||
exports.createCastleFromParts = (parts) => { | ||
exports.toCastleParts = toCastleParts; | ||
const createCastleFromParts = (parts) => { | ||
const servicesStatus = new Map(); | ||
@@ -88,2 +97,4 @@ const { producer, consumers, kafka } = parts; | ||
}; | ||
exports.createCastle = (config) => exports.createCastleFromParts(exports.toCastleParts(config)); | ||
exports.createCastleFromParts = createCastleFromParts; | ||
const createCastle = (config) => exports.createCastleFromParts(exports.toCastleParts(config)); | ||
exports.createCastle = createCastle; |
@@ -5,3 +5,3 @@ "use strict"; | ||
const util_1 = require("util"); | ||
exports.table = (rows) => { | ||
const table = (rows) => { | ||
const columns = rows[0].map((_, index) => rows.map(row => row[index])); | ||
@@ -13,7 +13,9 @@ const columnLengths = columns.map(column => column.reduce((len, item) => Math.max(len, item.length), 0)); | ||
}; | ||
exports.describeTopicAliases = (topicAlias) => { | ||
exports.table = table; | ||
const describeTopicAliases = (topicAlias) => { | ||
const maps = Object.entries(topicAlias); | ||
return maps.length ? `Topic Aliases:\n${exports.table(maps)}\n` : undefined; | ||
}; | ||
exports.describeCastleConsumers = (castleConfigs) => { | ||
exports.describeTopicAliases = describeTopicAliases; | ||
const describeCastleConsumers = (castleConfigs) => { | ||
const titles = ['Topic', 'Original Topic', 'Type', 'Group', 'Concurrency', 'From Beginning']; | ||
@@ -34,3 +36,4 @@ const descriptions = castleConfigs.map(({ config, instance }) => { | ||
}; | ||
exports.describeCastle = (castle) => { | ||
exports.describeCastleConsumers = describeCastleConsumers; | ||
const describeCastle = (castle) => { | ||
const descriptionRows = [ | ||
@@ -44,1 +47,2 @@ exports.describeTopicAliases(castle.kafka.topicsAlias), | ||
}; | ||
exports.describeCastle = describeCastle; |
@@ -5,3 +5,3 @@ "use strict"; | ||
const chunk = require("lodash.chunk"); | ||
exports.withEachSizedBatch = (eachSizedBatch, maxBatchSize) => async (payload) => { | ||
const withEachSizedBatch = (eachSizedBatch, maxBatchSize) => async (payload) => { | ||
const { batch: { messages }, isRunning, isStale, commitOffsetsIfNecessary, heartbeat, resolveOffset, } = payload; | ||
@@ -45,1 +45,2 @@ const chunks = chunk(messages, maxBatchSize); | ||
}; | ||
exports.withEachSizedBatch = withEachSizedBatch; |
@@ -5,4 +5,6 @@ "use strict"; | ||
const kafkajs_1 = require("kafkajs"); | ||
exports.isBatch = (paylaod) => 'batch' in paylaod; | ||
exports.isMessage = (paylaod) => 'message' in paylaod; | ||
const isBatch = (paylaod) => 'batch' in paylaod; | ||
exports.isBatch = isBatch; | ||
const isMessage = (paylaod) => 'message' in paylaod; | ||
exports.isMessage = isMessage; | ||
exports.defaultOptions = { | ||
@@ -38,3 +40,3 @@ consume: (ctx) => { | ||
}; | ||
exports.createLogging = (logger, userOptions = {}) => (next) => async (ctx) => { | ||
const createLogging = (logger, userOptions = {}) => (next) => async (ctx) => { | ||
const options = { ...exports.defaultOptions, ...userOptions }; | ||
@@ -55,2 +57,3 @@ try { | ||
}; | ||
exports.createLogging = createLogging; | ||
const stringLevel = { | ||
@@ -63,4 +66,5 @@ [kafkajs_1.logLevel.NOTHING]: 'error', | ||
}; | ||
exports.toLogCreator = (logger) => () => ({ level, log: { message, ...extra } }) => { | ||
const toLogCreator = (logger) => () => ({ level, log: { message, ...extra } }) => { | ||
logger.log(stringLevel[level], message, extra); | ||
}; | ||
exports.toLogCreator = toLogCreator; |
{ | ||
"name": "@ovotech/castle", | ||
"version": "0.6.3", | ||
"version": "0.6.4", | ||
"main": "dist/index.js", | ||
@@ -12,20 +12,20 @@ "types": "dist/index.d.ts", | ||
"devDependencies": { | ||
"@types/jest": "^26.0.14", | ||
"@types/jest": "^26.0.16", | ||
"@types/lodash.chunk": "^4.2.6", | ||
"@types/node": "^14.11.2", | ||
"@types/pg": "^7.14.5", | ||
"@types/node": "^14.14.10", | ||
"@types/pg": "^7.14.7", | ||
"@types/uuid": "^8.3.0", | ||
"@typescript-eslint/eslint-plugin": "^4.2.0", | ||
"@typescript-eslint/parser": "^4.2.0", | ||
"eslint": "^7.9.0", | ||
"eslint-config-prettier": "^6.11.0", | ||
"jest": "^26.4.2", | ||
"pg": "^8.3.3", | ||
"prettier": "^2.1.2", | ||
"slonik": "^22.5.0", | ||
"ts-jest": "^26.4.0", | ||
"@typescript-eslint/eslint-plugin": "^4.9.0", | ||
"@typescript-eslint/parser": "^4.9.0", | ||
"eslint": "^7.14.0", | ||
"eslint-config-prettier": "^6.15.0", | ||
"jest": "^26.6.3", | ||
"pg": "^8.5.1", | ||
"prettier": "^2.2.1", | ||
"slonik": "^23.0.3", | ||
"ts-jest": "^26.4.4", | ||
"ts-node": "^9.0.0", | ||
"ts-retry-promise": "^0.5.0", | ||
"typescript": "^4.0.2", | ||
"uuid": "^8.3.0", | ||
"ts-retry-promise": "^0.6.0", | ||
"typescript": "^4.1.2", | ||
"uuid": "^8.3.1", | ||
"winston": "^3.3.3" | ||
@@ -45,7 +45,7 @@ }, | ||
"dependencies": { | ||
"@ovotech/avro-kafkajs": "^0.5.5", | ||
"kafkajs": "^1.14.0", | ||
"@ovotech/avro-kafkajs": "^0.6.1", | ||
"kafkajs": "^1.15.0", | ||
"lodash.chunk": "^4.2.0" | ||
}, | ||
"gitHead": "954b9554464105ed6548fd2a22536ac943fe9d04" | ||
"gitHead": "6034a6bcd68d44cf9f3c6b0724ee759cc5a4aca9" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
34086
378
+ Added@ovotech/avro-kafkajs@0.6.3(transitive)
- Removed@ovotech/avro-kafkajs@0.5.5(transitive)
Updated@ovotech/avro-kafkajs@^0.6.1
Updatedkafkajs@^1.15.0