Skip to content

Instantly share code, notes, and snippets.

View tzachz's full-sized avatar

Tzach Zohar tzachz

View GitHub Profile
@tzachz
tzachz / tasks.py
Created January 30, 2024 23:09
Source Config Invoke Tasks
@task
def nightly_test(ctx):
"""---> Run Component Tests (Behave) - nightly scenarios """
ctx.run("behave tests/features --no-capture --no-capture-stderr --tags=nightly")
@task
def release_test(ctx):
"""---> Run Component Tests (Behave) - release scenarios"""
ctx.run("behave tests/features --no-capture --no-capture-stderr --tags=release")
@tzachz
tzachz / amazon_brazil_v2.feature
Created January 30, 2024 22:56
Source Config Behave test example
Feature: test source amazon_brazil_v2
@release
Scenario: release test
When I apply source amazon_br_v2.json to cached htmls amazon_br_v2.response.json for the following queries
| queries |
| B079FX76R9 |
Then I expect response to match the scraped items in amazon_br_v2.response.json
@nightly
@tzachz
tzachz / deployment.yml
Created July 25, 2022 17:28
Beating Conway’s Law: Achieving Distributed Ownership with Guice, RabbitMQ and Kubernetes - code snippet 5
apiVersion: apps/v1
kind: Deployment
metadata:
name: publisher-report-fetcher-prod-amazon
spec:
replicas: 3
template:
metadata:
labels:
app: publisher-report-fetcher-prod
@tzachz
tzachz / app.yml
Created July 25, 2022 17:26
Beating Conway’s Law: Achieving Distributed Ownership with Guice, RabbitMQ and Kubernetes - code snippet 4
guice.modules: ${GUICE_MODULES:-[
"io.skai.publisherreportfetcher.amazon.AmazonModule",
"io.skai.publisherreportfetcher.google.GoogleModule",
# … all other modules
]}
@tzachz
tzachz / PublisherRegistry.scala
Created July 25, 2022 17:25
Beating Conway’s Law: Achieving Distributed Ownership with Guice, RabbitMQ and Kubernetes - code snippet 3
@Singleton
class PublisherRegistry @Inject()(publishers: Seq[Publisher]) {
def getPublisher(publisherType: PublisherType): Publisher = publishers
.find(_.publisherType == publisherType)
.getOrElse(failGracefully(publisherType))
}
@tzachz
tzachz / GoogleModule.scala
Created July 25, 2022 17:24
Beating Conway’s Law: Achieving Distributed Ownership with Guice, RabbitMQ and Kubernetes - code snippet 2
class GoogleModule extends AbstractModule {
override def configure(): Unit = {
// Register your implementation of Publisher by adding it to the set:
Multibinder.newSetBinder(binder, classOf[Publisher])
.addBinding()
.to(classOf[GooglePublisher])
}
}
@tzachz
tzachz / ExponentialBackoffRetry.scala
Created December 6, 2019 23:58
ExponentialBackoffRetry.scala
package com.tzachz.retry
import akka.actor.ActorSystem
import akka.pattern.Patterns.after
import scala.concurrent.duration._
import scala.concurrent.{ExecutionContext, Future}
import scala.reflect.ClassTag
/**
@tzachz
tzachz / Matchers.java
Created September 17, 2019 19:06
Mockito gotcha: matchers sources
public static <T> T any() {
return (T) anyObject();
}
public static <T> T anyObject() {
return (T) reportMatcher(Any.ANY).returnNull();
}
@tzachz
tzachz / SpecDetail.scala
Created September 17, 2019 19:03
Mockito gotcha: detail
private def answerSizeOfInputPlus(add: Int): Answer[Int] = invocation => {
val inputArg: String = invocation.getArgumentAt(0, classOf[String])
inputArg.length + add
}
@tzachz
tzachz / MockitoCore.java
Created September 17, 2019 18:56
Mockito gotcha: mockito impl
public <T> OngoingStubbing<T> when(T methodCall) {
mockingProgress.stubbingStarted();
return (OngoingStubbing) stub();
}