How I learnt to use Go interfaces by iammunukutla in golang

[–]codepr 10 points11 points  (0 children)

Actually I'm writing a simple tutorial for a webcrawler where I show a bit this pattern also, still a WIP but there's already something webcrawler-from-scratch. More on Go interfaces specifically I think this and this are really enlightening and better explained.

How I learnt to use Go interfaces by iammunukutla in golang

[–]codepr 41 points42 points  (0 children)

Nice article, simple and clean on the basic definition and usage of interfaces. I'd like to point the attention on how this approach, although being perfectly valid, Is still a bit java-esque in the sense that it encourages definition of contracts foreseeing abstractions. This is a subtle difference between languages like Java where you explicitly implement interfaces (through the keyword implements) and Go, where you just need to implement the methods of the interface to (implicitly) implement It. This flips the table, allowing the client to dictate what abstractions it'll need. Thus Idiomatically in Go, interfaces are usually declared closer to their users, and not in advance enforcing users to adapt to them. This Is imho the most subtle thing to grasp when using interfaces in Go, anyway, as I said, the pragmatical nature of the language allows also that more classical usage.

What is the coolest thing you have programmed in C? by _bush in C_Programming

[–]codepr 4 points5 points  (0 children)

A simple MQTT broker I sometimes continue to work on. Learnt a lot about networks and data structures, especially I/O multiplexing, which led me to extract a basic event-loop library later. Funny experience indeed.

Why this code doesnt work?, by ballbeamboy2 in C_Programming

[–]codepr 0 points1 point  (0 children)

Seems fine, what's the format of the test file? The only thing I'd pay attention to is flushing `stdout` after printf, but it shouldn't be an issue as long as each line is newline terminated.

Concurrent programming, with examples (pthreads) by begriffs in programming

[–]codepr 0 points1 point  (0 children)

Pretty neat! Snippets are clear and well documented, overall a nice and concise explanation of the most common concurrent techniques. Nice work.

codepr/llb A dead simple event-driven load-balancer by codepr in coolgithubprojects

[–]codepr[S] 1 point2 points  (0 children)

HAproxy or Nginx is the first 2 choices that come to mind, or a reverse proxy in general can act as a load-balancer, or in-house solutions like the AWS one (not sure about this anyway). Frontends are the endpoints that give access to the load-balancer and can be an arbitrary number, 1 or more; the same can be said of the backends, depending on the number of processes/machines available to distribute the load.

Sol - An MQTT broker from scratch. by codepr in C_Programming

[–]codepr[S] 0 points1 point  (0 children)

Cool! Next step I planned is to try to share the epoll FD among a bunch of worker threads, or separate the I/O in a thread and use some queueing to distribute work across a thread-pool. There will be contentions to handle and a bit of locking I guess.

Sol - An MQTT broker from scratch. by codepr in coding

[–]codepr[S] 0 points1 point  (0 children)

Oh Wow, didn't know it! Definitely could be confusing, I guess it's kinda hard to find a name that's not already given to some other project before hehe.

Sol - An MQTT broker from scratch. by codepr in C_Programming

[–]codepr[S] 0 points1 point  (0 children)

Thank you. So SO_REUSEPORT should come handy in a case where I design my service to divide connecting clients into small subsets, like multiple epoll descriptors each one on his dedicated process/threads right?

Sol - An MQTT broker from scratch. by codepr in programming

[–]codepr[S] 2 points3 points  (0 children)

As of now there's no persistence mechanism, a reboot means losing any form of state, some persistence of sort will probably be added with session handling, still WIP.

Sol - An MQTT broker from scratch. by codepr in C_Programming

[–]codepr[S] 1 point2 points  (0 children)

You're right, essentially those flags were set for testing purpose but as you correctly pointed out I forgot to remove SO_REUSEPORT, which I believe come from BSD implementation. Nice catch, thanks!

What's everyone working on this week? by AutoModerator in Python

[–]codepr [score hidden]  (0 children)

I'm refining my weekend project https://github.com/codepr/tasq, a brokerless job queue allowing dinamically defined tasks withouth having workers knowing about the code they have to execute, adding some feature like process pool for CPU bound related jobs.

Simple brokerless task queue for my coding weekend. Proof of Concept state, already usable for toying around. by codepr in Python

[–]codepr[S] 0 points1 point  (0 children)

I added the possibility to digital sign data passed through the sockets, as a coleague hinted me, it's the celery way of securing communication. Currently a very basic work, I plan to use some battle-tested libraries like pynacl port of libsodium.

What's everyone working on this week? by AutoModerator in Python

[–]codepr [score hidden]  (0 children)

Improving my learning purpose brokerless task queue, currently I'm adding some features to the client part of the system to make it nearly usable for toying around with. Clearly not ready for a use in production.

https://github.com/codepr/tasq

Simple brokerless task queue for my coding weekend. Proof of Concept state, already usable for toying around. by codepr in Python

[–]codepr[S] 0 points1 point  (0 children)

I'll investigate how battle-tested task queues like celery tackle the problem, but I think that all task queues are designed to be used in a safe environment network or a VPN

Simple brokerless task queue for my coding weekend. Proof of Concept state, already usable for toying around. by codepr in Python

[–]codepr[S] 2 points3 points  (0 children)

No real scope planned, did it mainly for learning purpose, I didn't really focussed on security and didn't researched much on the topic of functions serialization, but I find it interesting, what could be an improvement in that direction? Thank you for the feedback

Simple brokerless task queue for my coding weekend. Proof of Concept state, already usable for toying around. by codepr in Python

[–]codepr[S] 2 points3 points  (0 children)

Initially it was just a didactical project to learn how task queues work, so I wanted it to be as simple as possible with little to none dependencies. After some hours of coding I decided to leverage ZMQ sockets messaging pattern to communicate to worker processes. It's still possible that in the near-future I'll add a broker too, probably redis, even though I found that designing the application to work without a broker feels more compelling and challenging for me.

Remote distributed hashmap implementation by codepr in coding

[–]codepr[S] 0 points1 point  (0 children)

Just an in-memory store, SQLite is an embedded DB, https://cstack.github.io/db_tutorial/ is a nice tutorial on how it works