Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

C version. #8

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,16 @@ coverage

# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release
lib
/lib

# Dependency directory
# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git
node_modules
test/dump

# So o files
*.so
*.o
*.lo
.vscode
/csrc/lib/jansson/*
4 changes: 3 additions & 1 deletion .npmignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
test
test
.vscode
csrc/lib/jansson
9 changes: 5 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,18 @@ BABEL := ./node_modules/.bin/babel
THIS_FILE := $(lastword $(MAKEFILE_LIST))

BUILD_DIR := ./lib
SOURCES := index.js filtered-list-bust.lua sorted-filtered-list.lua groupped-list.lua
SOURCES := index.js

$(BUILD_DIR)/%.js: %.js
$(BABEL) $*.js -d $@

$(BUILD_DIR)/%.lua: %.lua
cp $*.lua $@

clean:
rm -rf $(BUILD_DIR)

build: $(foreach src, $(SOURCES), $(BUILD_DIR)/$(src))

all: clean build

redis-module:
make -C csrc/ build

7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,16 @@

[![Build Status](https://travis-ci.org/makeomatic/redis-filtered-sort.svg)](https://travis-ci.org/makeomatic/redis-filtered-sort)

Exports LUA script, which is able to perform multi filter operations, as well as sorts
Wraps Redis `FilterSortModule` api, which is able to perform multi filter operations, as well as sorts

This basically replicates `http://redis.io/commands/sort` but with extra features and ability to run it in clustered mode with
hashed keys, which resolve to the same slot

## Dependencies
Redis must have `FilterSortModule` enabled.
Please see [HOWTO](./doc/build.md) build module.
API provided by module in [API](./doc/api.md).

## Installation

`npm i redis-filtered-sort -S`
Expand Down
7 changes: 7 additions & 0 deletions csrc/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
*.o
*.a
*.so
*.db
.vscode
lib/rmutil/test_vector

41 changes: 41 additions & 0 deletions csrc/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
include variables.include

ifdef IMAGE_NAME
DOCKER_IMAGE = $(IMAGE_NAME)
endif

all: clean build

docker-push:
docker push $(DOCKER_IMAGE)

docker-build:
docker build . -f ./docker/Dockerfile -t $(DOCKER_IMAGE)
docker-rebuild:
docker build . --no-cache -f ./docker/Dockerfile -t $(DOCKER_IMAGE)

build:
cd redis-filtered-sort && $(MAKE) all

clean:
cd redis-filtered-sort && $(MAKE) $@

deps: jansson


clean-deps:
rm -rf $(JANSSON_LIBDIR)/*

jansson: jansson_src jansson_configure
(cd $(JANSSON_LIBDIR) && make CFLAGS='$(CFLAGS)')

jansson_configure:
(cd $(JANSSON_LIBDIR) && ./configure)

jansson_clean:
(cd $(JANSSON_LIBDIR) && make clean)

jansson_src: $(JANSSON_LIBDIR)/src/jansson.h

$(JANSSON_LIBDIR)/src/jansson.h:
mkdir -p $(JANSSON_LIBDIR) && wget -O- $(JANSSON_LINK) | tar xvz --directory=$(JANSSON_LIBDIR) --strip-components=1 jansson-$(JANSSON_VERSION)
20 changes: 20 additions & 0 deletions csrc/docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
FROM alpine AS build-mod
RUN apk add --no-cache --virtual .build-deps \
coreutils \
gcc \
linux-headers \
make \
musl-dev \
&& apk add \
bash
RUN mkdir /src
WORKDIR /src

ADD . /src/
RUN make deps && make

FROM redis:5.0.5-alpine
COPY --from=build-mod /src/redis-filtered-sort/filter_module.so /usr/local/lib/redis_filtered_sort.so
ENTRYPOINT ["docker-entrypoint.sh"]
CMD ["redis-server", "--loadmodule", "/usr/local/lib/redis_filtered_sort.so"]
EXPOSE 6379
Empty file added csrc/lib/jansson/.gitkeep
Empty file.
Loading