Implementing redis in go [closed] - go

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I am trying implement redis basic functionality like below in Go.
GET
SET
ZADD
ZCARD
ZCOUNT
ZRANGE
SAVE

If you want to implement a Go server offering some Redis features, it is quite easy. You need to decide about the goroutine model, then implement/reuse some data structures (map and skiplist), then implement the Redis protocol (which is simple enough).
I would suggest a goroutine model with 2 goroutines per client connection, plus one goroutine to implement the Redis engine and manage the data structures. The benefit of this model is you can easily support pipelining and the atomicity property of Redis commands without any explicit locking. This model is well adapted if you want to later extend the scope by supporting blocking commands (such as the ones useful for queues).
Now, if you also want to mimic the same exact Redis behavior, this is more complex. Especially, saving the data in background leveraging the OS copy-on-write mechanism will be difficult with Go (since forking does not work). For a memory database, foreground saving is always easy. Background saving is extremely difficult.
You may also want to have a look at the following attempts, and simplify/enrich them to match your goals:
https://github.com/siddontang/ledisdb
https://github.com/felixge/go-redis
https://github.com/docker/go-redis-server

Related

Laravel - Is there a pattern for creating complex scheduled tasks? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 3 days ago.
Improve this question
I am creating several scheduled tasks within my Laravel site using the schedule() function within the Console/Kernel object. It acceptable to place simple logic in the schedule() function (based on the explanation from the Laravel site):
$schedule->call(function () {
DB::table('recent_users')->delete();
})->daily();
However, if the logic needs to be more complicated (100 lines of code or more to decide which models to focus on) basic programming rules instructs us to break the code up into additional functions and classes, which can be then be called by schedule(). However, I am a bit confused as to where these functions/classes go. A few possibilities:
A Controller function, even though it does not use a route?
A trait, used by the Kernel?
Console command, even though it's never called from the console?
A helper?
(edit) Other classes that share the Kernel's namespace?
Another kind of class that functions like a Controller, but internally only? (Something that I am not aware of.)
Where do these classes/functions go?
====
There are many established patterns can be regarded as correct or incorrect, based on Laravel's intended use, regardless of opinion. Also, there are many valid ways in which Laravel can be used. Within this context, there are many opinions on the best way to do things, many of which could be considered correct. That said, there are framework design patterns which are beyond the scrutiny of opinion (for now.) We use routes to link URLs to Controllers (not jobs.) We access models from the controllers and not the other way around. My question is intended to discover an established pattern that I am not aware of, and not to debate opinions regarding these patterns.
Basically, I want to avoid building my site in a way that with prove blatantly embarrassing in the future, (especially regarding lesser well known site elements, such as jobs, scheduling and console commands) simply because I did not know Laravel facts.

How to start implementing a Linux ECC block device wrapper [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
Thinking about student projects to advise; I'm an OK C develepor and C++ developer/architect.
Not done much Linux kernel development beyond "write your first module".
The thing I want to rudimentarily implement (before advising students doing it properly as a team project) is:
Take existing block device, say /dev/sda
add second block device, say /dev/fec0, which implements wrapper around first, providing error-correction on read and writing data + error coding information on write
This implies that the size of fec0 is smaller than that of sda. Also, note that this is somewhat different to the RAID5 approach, as there's no split of parity data to secondary data groups or similar.
Now, I'm trying to get an overview of how to do this. It's clear that it will be necessary, aside from implementing the block device interface itself, to implement a control interface to define things like "use /dev/sda to create fec0", "shut down fec0".
The questions that arise are:
Is there a preferred framework to integrate this into? Goal is finding the sensible place to put this. To mind come:
dmraid and
lvm2, or
just a plain block device driver
How to implement control interfacing?
Specific ioctls?
/sys/* pseudofile interface?
framework-specific ways?
For the first part of your question, I'd suggest you have two choices: the block subsystem or the md (multiple device) subsystem. I think the most useful thing I could do would be to point you in the direction of some references so you can decide what fits best. If you want to account for logical volumes then see here for the lvm-raid man page which sits in both the md and dm subsystems. If you just want to restrict yourself to RAID functionality, then see here for the md driver man page. But if you want to keep it simple and just make a wrapper over a simple block device, perhaps emulating some aspects of lvm and raid, then add a driver to the block subsystem.
Your choice would affect the second part of your question, too. Single block devices commonly provide lots of ioctls; md drivers make a lot of use of the sysfs interface. Hope that's helpful.

Is Spring JdbcTemplate faster than Spring Data Jpa? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
Our client force us to use JdbcTemplate instead of Spring Data Jpa for the development of the Spring project. However, the application is not critical in terms of speed and delivery of responses (it is an internal web application for the client's end-users).We would like to use Spring Data Jpa.
Question: Is there some objective reason to use JdbcTemplate because the speed of the application? From my point of view there will be different bottlenecks.
The question, what is faster is impossible to answer without specifying an exact use case.
JdbcTemplate will most likely be faster when talking about pure query execution, because a JPA implementation will do more stuff:
Parse JPQL (assuming you are using that)
creating a SQL query out of that
executing it
converting the result into objects
While the template will (almost) just:
execute the query
hand you the result as a call to ResultSetMapper or similar.
Of course JPA does all of this for a reason.
it offers a reasonable amount of database independence.
it tracks your changes and generates the right update statements for persisting them.
it allows for lazy loading so you don't have to think about what to load before hand (of course you still have to do that if you care about performance).
And those things have costs beyond performance.
The abstraction JPA offers is actually really complex and leaky and it is not properly understood by most developers using it. While I think it is completely reasonable to use JPA in many contexts, I can also relate to people banning it from their projects. Talking about performance is absolutely too limited in order to make a well-educated decision on this.

Design patterns for shared state with many to many streaming [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 4 years ago.
Improve this question
I'm writing an online whiteboard application for fun, where multiple users view the same whiteboard and can draw on it. I'm using websockets (vanilla JS on the frontend, Scala on the backend), and right now am essentially just broadcasting mouse events from one user to the rest of the users, and rendering the image client-side.
However, this results in a transient shared state, whereas I would like to have users be able to hop on at any time and see the preserved shared state. I'm thinking this will probably require having shared rendering code on the backend and the frontend, so that clients render events as they stream but the server can send raw image data when clients associate.
So my question here is: what are some other design patterns I should be aware of for this kind of project? This is a for fun/learning project, so this is an open-ended question, but I'll accept an answer that contains some useful references for this kind of data flow.
So my question here is: what are some other design patterns I should
be aware of for this kind of project?
You don't have to have rendering code on the server. You can just save all the accumulated events that led to the current whiteboard and send those to a new client and let the new client render the whiteboard for itself as if they were listening when all the events originally happened.
If that's more data than is practical, then you can compress raw events. For example a straight or nearly straight line segment does not need all the intervening mouse positions, it really just needs the first and last position of the segment.

New to ABAP GUI Programming - what to learn? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
I am new to ABAP programming. To prepare myself for my new job, I am reading ABAP books. During reading, I learned that ABAP has several legacy elements to keep it backwards compatible with older SAP releases.
Regarding GUIs, I am reading about SAP-UI (PARAMETERS, etc.) Dynpros and WebDynpros. Now, I am unsure about on what to focus my learning efforts on.
Are the common rules like "You should know a little about basic SAP-UI, but mainly focus on WebDypros."
Background information: My new employee does SAP customizing for small and medium sized enterprises.
I'm not a consultant, but I work for a medium (~120 employees) sized company myself. If you were to work for us you would mostly create custom abap reports, maybe sometimes program a user exit. Small companies usually don't spend the money needed for big SAP driven portals, so they probably don't use Netweaver AS Java at all. That means abap dynpro and abap lists as your main UI elements. Sometimes it is good to also know your way around other ways of creating reports, for instance SAP Query.
If I were you I would start with basic abap. You won't have any fun working with dynpros if you haven't gotten your head around the basic stuff first. Learn to work with internal tables, work areas, field symbols. Have a look at some basic ABAP Objects stuff (for instance the ALV grid, very useful for displaying all sorts of tables). You should also understand the ABAP Dictionary, the place where structures, tables, data elements, data domains ans search helps are defined.

Resources