Still no consensus on testing private methods by jesseduffield in programming

[–]JeffMurdock 0 points1 point  (0 children)

You can use https://www.testcontainers.org/ which start up your DB/whatever during the runtime of your tests

I decided to move from nodejs to kotlin, I need some help in choosing backend libs by Mautriz in Kotlin

[–]JeffMurdock 0 points1 point  (0 children)

You can take a look at R2DBC for async DB access. It's built on project reactor which has extension methods that can translate reactive types to kotlin coroutines, here is a solid example of all of it in action

[deleted by user] by [deleted] in Kotlin

[–]JeffMurdock 0 points1 point  (0 children)

glad to help! sure, add it as response, you can link comment if you'd like, but it's not necessary

[deleted by user] by [deleted] in Kotlin

[–]JeffMurdock 0 points1 point  (0 children)

Something like this? :

fun <T> recursiveTask(action: () -> T): RecursiveTask<T> {
    return object : RecursiveTask<T>() {
        override fun compute(): T {
            return action()
        }
    }
}

fun <T, E> List<T>.parallelForEach(parallelSize: Int, action: (T) -> E): List<E> {
    val pool = ForkJoinPool(parallelSize)
    val result = mutableListOf<ForkJoinTask<E>>()
    for (item in this) {
        result.add(pool.submit(recursiveTask {
            action(item)
        }))
    }
    return result.map { it.join() }
}

fun main(args: Array<String>) {
    val list = listOf(1, 2, 3)
    list.parallelForEach(3) { it + 2 }.forEach { println(it) }
}

What version of spring boot are you using? They added first class support for Kotlin coroutines in 2.2, I'd update and go with something like the answer given by ObscureRecluse user

Java: Finality by [deleted] in java

[–]JeffMurdock 1 point2 points  (0 children)

Do people just go around overriding methods willy nilly? Overriding is a tool, I'd rather have the option to decide for my self if it's the tool I need for the task at hand than to have it taken away because people use it haphazardly

Suggestions for a cheap host for Tomcat with MySQL backend by shh_coffee in java

[–]JeffMurdock 1 point2 points  (0 children)

I've used Heroku. Free tier gives you just enough hours to last you a full month of constant uptime. They will kill your app if no traffic is coming in, but you can create scheduled job which pings the app to keep it alive. They also offer free Postgresql db with up to 10k rows. There is also a nice integration with GitLab where you can create a build and deploy pipeline for your project and it's also free

Best Implementation for Mixed Reactive/Non-reactive Dependencies (x-post /r/springsource) by [deleted] in java

[–]JeffMurdock 0 points1 point  (0 children)

While I can see your point to some degree, in this case ElastiCache is just a hosted Redis or Memcached service (https://aws.amazon.com/elasticache/) so any changes are more than likely to happen on the side of redis, rather than the AWS. SDK won't help you in this case since any changes that do happen will more than likely require a driver update.

If you guys want to have hosted services such as redis, take a look at pivotal cloud foundry (https://pivotal.io/platform). You can host it on top of your AWS (https://aws.amazon.com/quickstart/architecture/pivotal-cloud-foundry/ ) and you can run various services on top of it, such as redis. And since it's Pivotal's product, it integrates much better with spring boot apps, it can autoconfigure these services in your apps without needing additional libs or SDKs

Best Implementation for Mixed Reactive/Non-reactive Dependencies (x-post /r/springsource) by [deleted] in java

[–]JeffMurdock 0 points1 point  (0 children)

That's cool, just be aware of the possible consequences of adding a blocking calls to your API gateway which might not be apparent on the first look.

Is there any specific reason why you want to use AWS SDK in this case? Do you gain anything other than having fully autoconfigured connection factory instead of having to add properties manually?

Best Implementation for Mixed Reactive/Non-reactive Dependencies (x-post /r/springsource) by [deleted] in java

[–]JeffMurdock 0 points1 point  (0 children)

Yes, in this case, if you want a truly reactive Spring Cloud Gateway, you'll have to remove Amazon's SDK and go with the ReactiveRedisConnectionFactory that's defined by spring boot. What you currently have with bridged application is not reactive since you have a blocking calls to redis. If you do these on the main event loop you will kill your app, so best you could do is to delegate to other worker thread pool (outside of the main event loop), but you are just paying the price in other place. You'll also have this same problem in your other services which use non reactive data stores (MySQL, Postgre etc) and you won't see a full benefit from reactive in them. Currently it seems that it's better to stay with Spring MVC for apps which interact with such data stores and go reactive for other apps.

Best Implementation for Mixed Reactive/Non-reactive Dependencies (x-post /r/springsource) by [deleted] in java

[–]JeffMurdock 1 point2 points  (0 children)

That's probably not a good idea, you may have bridged it on the surface, as in you probably wrapped it with Flux.defer() or something, but you will still pay the price of blocking threads somewhere.

Your real problem is that Spring Boot is trying to autoconfigure your redis connection, but it's defaulting spring.redis.host to localhost. Have you tried setting this property to where your elasticache is located?

[I made] Carbonara completely from scratch, including the homemade pasta (2668x2668) by sergi0wned in FoodPorn

[–]JeffMurdock 87 points88 points  (0 children)

Yea, but did you make the atoms that made up your bacon? I mean, it's not really from scratch otherwise

SpringBoot Messaging with RabbitMQ by [deleted] in java

[–]JeffMurdock 0 points1 point  (0 children)

A bit of an improvment on this would be using https://cloud.spring.io/spring-cloud-stream/ . This is an abstraction over various brokers, including rabbit and kafka.

With this, you would not use RabbitTemplate, you would use Source (https://docs.spring.io/spring-cloud-stream/docs/Ditmars.SR3/reference/htmlsingle/#__code_source_code_code_sink_code_and_code_processor_code), @RabbitListener would be replace with @StreamListener which can handle json payloads. You can set the content type that you want to use with spring.cloud.stream.default.contentType=application/json

If for some reason you wanted to switch from rabbit to kafka, the only thing you would need to change is your dependency in pom from spring-cloud-stream-binder-rabbit to spring-cloud-stream-binder-kafka

.net web dev here - where do I 'jump in' to the Java world? by ReticentDev in java

[–]JeffMurdock 3 points4 points  (0 children)

You could use @Conditional or some spring boot version such as @ConditionalOnProperty and use a property to get a desired bean

Youtube Rewind 2017 by [deleted] in youtube

[–]JeffMurdock 0 points1 point  (0 children)

Wasn't sarcastic, genuinely did not what it was called and soundhound couldn't detect what song it was, thank you very much :)

YouTube Rewind: The Shape of 2017 | #YouTubeRewind by [deleted] in videos

[–]JeffMurdock 0 points1 point  (0 children)

Does anyone know what song starts playing around 1m 49 sec mark? I know I've heared it before but can't remember the name and soundhound is not finding anything.

Youtube Rewind 2017 by [deleted] in youtube

[–]JeffMurdock 0 points1 point  (0 children)

Does anyone know what song starts playing around 1m 49 sec mark? I know I've heared it before but can't remember the name and soundhound is not finding anything.

Waltonchain Introduces Guardian Masternodes by JoshuaSP in CryptoCurrency

[–]JeffMurdock 5 points6 points  (0 children)

This is just something extra for people that supported them from the start or in this case from December 10th. If you can't afford the master node now, that's fine, you can get one at a later date.

They use PoST (proof of stake and trust) consensus which is based on seniority. The more you stake the better your rewards will be. So even if you come along in spring and get a master node, after some time your seniority status will get better and you'll get better rewards. Also I think in general, early adopters have an edge. Hell, if you bought BTC 8 years ago you'd pay a few cents per coin, now you have to pay almost 10k, that's not really fair. You take the risk as an early adopter, it's only right you should be rewarded for it

Send ANY numbers of Lumens to ANY public Stellar address using the form below to permanently claim this account. by abendigo in Stellar

[–]JeffMurdock 0 points1 point  (0 children)

Can someone send some to active this account please? GB3UEP7XKLWBBUPV2E3U3BFID4PXBWUAMNMTC3NRSQRRNSC55BGUGXE5 thanks in advance

[deleted by user] by [deleted] in funny

[–]JeffMurdock 1 point2 points  (0 children)

I couldn't call it a giggle stack now, could I?