This repository has been archived by the owner on Sep 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
132 changed files
with
17,350 additions
and
5,798 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,33 @@ | ||
|
||
# Created by https://www.gitignore.io/api/java,maven | ||
# Created by https://www.gitignore.io/api/go | ||
|
||
### Maven ### | ||
target/ | ||
pom.xml.tag | ||
pom.xml.releaseBackup | ||
pom.xml.versionsBackup | ||
pom.xml.next | ||
release.properties | ||
dependency-reduced-pom.xml | ||
buildNumber.properties | ||
.mvn/timing.properties | ||
### Go ### | ||
# Binaries for programs and plugins | ||
*.exe | ||
*.exe~ | ||
*.dll | ||
*.so | ||
*.dylib | ||
|
||
# Test binary, build with `go test -c` | ||
*.test | ||
|
||
### Java ### | ||
*.class | ||
# Output of the go coverage tool, specifically when used with LiteIDE | ||
*.out | ||
|
||
# Mobile Tools for Java (J2ME) | ||
.mtj.tmp/ | ||
### Vagrant ### | ||
# General | ||
.vagrant/ | ||
|
||
# Package Files # | ||
*.jar | ||
*.war | ||
*.ear | ||
# Log files (if you are creating logs in debug mode, uncomment this) | ||
# *.logs | ||
|
||
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml | ||
hs_err_pid* | ||
# End of https://www.gitignore.io/api/go | ||
|
||
### Stockpile ### | ||
logs/ | ||
/application.yml | ||
# dep | ||
vendor/ | ||
Gopkg.lock | ||
|
||
# Stockpile | ||
*.gen.go | ||
build/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
image: dotstart/go-dep:1.10.3 | ||
|
||
cache: | ||
paths: | ||
- /apt-cache | ||
- /go/src/golang.org | ||
- /go/src/google.golang.org | ||
- /go/src/gopkg.in | ||
|
||
before_script: | ||
- curl -sL https://deb.nodesource.com/setup_10.x | bash - | ||
- apt-get install -y curl git golang-goprotobuf-dev libprotobuf-dev nodejs protobuf-compiler | ||
- mkdir -p /go/src/github.com/dotStart /go/src/_/builds | ||
- cp -r $CI_PROJECT_DIR /go/src/github.com/dotStart/Stockpile | ||
- cd /go/src/github.com/dotStart/Stockpile | ||
|
||
after_script: | ||
- cp -r /go/src/github.com/dotStart/Stockpile/build $CI_PROJECT_DIR | ||
- cd $CI_PROJECT_DIR | ||
|
||
build: | ||
stage: build | ||
script: | ||
- make | ||
artifacts: | ||
name: Stockpile | ||
paths: | ||
- build/*.tar.gz |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
required = ["github.com/elazarl/go-bindata-assetfs"] | ||
|
||
[prune] | ||
go-tests = true | ||
unused-packages = true | ||
|
||
[[constraint]] | ||
name = "github.com/elazarl/go-bindata-assetfs" | ||
version = "1.0.0" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
APPLICATION_BRAND := vanilla | ||
APPLICATION_VERSION := 2.0-alpha | ||
APPLICATION_COMMIT_HASH := `git log -1 --pretty=format:"%H"` | ||
APPLICATION_TIMESTAMP := `date --utc "+%s"` | ||
|
||
GIT := $(shell command -v git 2> /dev/null) | ||
DEP := $(shell command -v dep 2> /dev/null) | ||
GO := $(shell command -v go 2> /dev/null) | ||
NODE := $(shell command -v node 2> /dev/null) | ||
NPM := $(shell command -v npm 2> /dev/null) | ||
export | ||
|
||
PLUGINS := $(wildcard plugins/*/.) | ||
|
||
all: check-env print-config install-dependencies core core-plugins package | ||
|
||
check-env: | ||
@echo "==> Checking prerequisites" | ||
@echo -n "Checking for git ... " | ||
ifndef GIT | ||
@echo "Not found" | ||
$(error "git is unavailable") | ||
endif | ||
@echo $(GIT) | ||
@echo -n "Checking for go ... " | ||
ifndef GO | ||
@echo "Not Found" | ||
$(error "go is unavailable") | ||
endif | ||
@echo $(GO) | ||
@echo -n "Checking for dep ... " | ||
ifndef DEP | ||
@echo "Not Found" | ||
$(error "dep is unavailable") | ||
endif | ||
@echo $(DEP) | ||
@echo -n "Checking for node ... " | ||
ifndef NODE | ||
@echo "Not Found" | ||
$(error "node is unavailable") | ||
endif | ||
@echo $(NODE) | ||
@echo -n "Checking for npm ... " | ||
ifndef NPM | ||
@echo "Not Found" | ||
$(error "npm is unavailable") | ||
endif | ||
@echo $(NPM) | ||
@echo "" | ||
|
||
print-config: | ||
@echo "==> Build Configuration" | ||
@echo "" | ||
@echo " Brand: ${APPLICATION_BRAND}" | ||
@echo " Version: ${APPLICATION_VERSION}" | ||
@echo " Commit SHA: ${APPLICATION_COMMIT_HASH}" | ||
@echo " Timestamp: ${APPLICATION_TIMESTAMP}" | ||
@echo "" | ||
|
||
clean: | ||
@echo "==> Clearing previous build data" | ||
@rm -rf build/ || true | ||
@$(GO) clean -cache | ||
|
||
install-dependencies: | ||
@echo "==> Installing dependencies" | ||
@$(GO) get -u github.com/elazarl/go-bindata-assetfs/go-bindata-assetfs | ||
@$(GO) get -u github.com/jteeuwen/go-bindata/go-bindata | ||
@$(DEP) ensure -v | ||
@echo "" | ||
|
||
core: | ||
@echo "==> Building stockpile" | ||
$(MAKE) -C stockpile/ | ||
|
||
core-plugins: | ||
@echo "==> Building core plugins" | ||
@for dir in $(PLUGINS); do \ | ||
"$(MAKE)" -C $$dir; \ | ||
done | ||
|
||
package: | ||
@echo "==> Creating distribution packages" | ||
@for dir in build/*; do if [ -d "$$dir" ]; then tar -czvf "$(basename "$$dir").tar.gz" --xform="s,$$dir/,," "$$dir"; fi; done | ||
@echo "" | ||
|
||
.PHONY: all |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,78 @@ | ||
# Stockpile ![State](https://img.shields.io/badge/state-prototype-orange.svg) [![Latest Tag](https://img.shields.io/github/release/lordakkarin/stockpile.svg)](https://github.com/LordAkkarin/Stockpile/releases) ![Latest Version](https://img.shields.io/maven-central/v/com.torchmind.lithium/parent.svg) [![Gitter](https://badges.gitter.im/LordAkkarin/Stockpile.svg)](https://gitter.im/LordAkkarin/Stockpile?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) | ||
Stockpile | ||
========= | ||
|
||
Stockpile is a lightweight caching server for the Minecraft API. | ||
Lightweight and protocol aware API proxy for the Mojang APIs. | ||
|
||
### Key Features | ||
**Looking for Stockpile 1.0?** Its source code may still be accessed [here](https://github.com/dotStart/Stockpile/tree/v1.0.0-SNAPSHOT) | ||
|
||
* **Customizable Caching Levels** | ||
allow you to tailor the application to your needs while ensuring you stay well below the rate limit. | ||
* **Comprehensive Java API** | ||
Key Features | ||
------------ | ||
|
||
## Need Help? | ||
* Customizable (broad configuration options and plugin support) | ||
* gRPC based (clients may be generated for most popular languages) | ||
* Completely Open Source | ||
|
||
The [official documentation][wiki] has help articles and specifications on the implementation. If, however, you still | ||
require assistance with the application, you are welcome to join our [Gitter Channel][gitter] and ask veteran users and | ||
developers. Make sure to include a detailed description of your problem when asking questions though: | ||
Installation & Setup | ||
-------------------- | ||
|
||
1. Include a complete error message along with its stack trace when applicable. | ||
2. Describe the expected result. | ||
3. Describe the actual result when different from the expected result. | ||
1. Download a binary release from the [releases page](https://github.com/dotStart/Stockpile/releases) | ||
or [build from source](#building) | ||
2. Extract or copy the Stockpile executable and plugin directory (if applicable) to a custom | ||
directory (convention for Linux systems is `/opt/stockpile`) | ||
3. Create a configuration file (for examples, refer to the `docs` directory in the source | ||
distribution) | ||
4. Start Stockpile via `./stockpile server -config=path/to/myconfig.hcl` | ||
|
||
[wiki]: https://github.com/LordAkkarin/Stockpile/wiki | ||
Note that you may additionally launch Stockpile in development mode via `./stockpile server -dev` in | ||
order to automatically select a set of acceptable default parameters without requiring a customized | ||
configuration file. | ||
|
||
## Contributing | ||
Once the server is running, you may access its functionality via the `stockpile` executable. Run | ||
`./stockpile help` for more information on the respective client commands. If configured you may | ||
also access the Web UI via `<your ip or hostname>:36623` (or wherever you configured Stockpile to | ||
listen) assuming that it has been enabled (the Web UI is enabled by default in development mode). | ||
|
||
See [CONTRIBUTING.md](CONTRIBUTING.md) for information on working on Stockpile and submitting patches. Related projects | ||
are listed on the [Implementations wiki page][implementations]. You can also join the [project's chat room][gitter] to | ||
discuss future improvements or to get your custom implementation listed. | ||
Prerequisites | ||
------------- | ||
|
||
[implementations]: https://github.com/LordAkkarin/Stockpile/wiki/Implementations | ||
[gitter]: https://gitter.im/LordAkkarin/Stockpile | ||
The following applications are required to be present within your system PATH when **building** the | ||
application from source (some may be omitted if you are willing to skip some of the build steps): | ||
|
||
* git (latest recommended) | ||
* go (1.10 or newer) | ||
* protobuf (including protobuf go plugin) | ||
* node & npm (latest recommended) | ||
|
||
Building | ||
-------- | ||
|
||
1. `go get -d -u github.com/dotStart/Stockpile/...` | ||
2. `cd $(go env GOPATH)/src/github.com/dotStart/Stockpile` | ||
3. `make` | ||
|
||
The resulting binaries will be located in the `build` directory. | ||
|
||
**Note:** Binaries built on Windows will not provide support for plugins (nor will they include the | ||
standard plugins). If you wish to build a version for distribution (or execution in a production | ||
environment), please build them on Linux (for instance, using the Vagrant configuration included | ||
within this repository). | ||
|
||
License | ||
------- | ||
|
||
``` | ||
Copyright [year] [name] <[email]> | ||
and other copyright owners as documented in the project's IP log. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# -*- mode: ruby -*- | ||
# vi: set ft=ruby : | ||
|
||
# --------------------------------------------------- # | ||
# DO NOT DEPLOY THIS IMAGE IN PRODUCTION ENVIRONMENTS # | ||
# --------------------------------------------------- # | ||
# This image is designed specifically for development # | ||
# purposes (specifically to develop and test plugins # | ||
# in environments where they are not natively # | ||
# supported (specifically Windows machines) # | ||
# --------------------------------------------------- # | ||
Vagrant.configure("2") do |config| | ||
config.vm.box = "ubuntu/bionic64" | ||
config.vm.network "forwarded_port", guest: 36623, host: 36623, host_ip: "127.0.0.1" | ||
config.vm.synced_folder ".", "/opt/go/src/github.com/dotStart/Stockpile" | ||
|
||
config.vm.provision "shell", inline: <<-SHELL | ||
echo "==> Initializing basic build environment" | ||
sudo apt-get update | ||
sudo apt-get install -y curl git golang golang-goprotobuf-dev make nodejs npm protobuf-compiler-grpc libprotoc-dev redis-server | ||
export GOPATH=/opt/go | ||
export PATH="$PATH:/opt/go/bin" | ||
if [ ! -f "$(go env GOPATH)/bin/dep" ]; then \ | ||
echo "==> Building go dep"; \ | ||
go get -d -u github.com/golang/dep; \ | ||
cd $(go env GOPATH)/src/github.com/golang/dep; \ | ||
DEP_LATEST=$(git describe --abbrev=0 --tags); \ | ||
git checkout $DEP_LATEST; \ | ||
go install -ldflags="-X main.version=$DEP_LATEST" ./cmd/dep; \ | ||
git checkout master; \ | ||
fi | ||
echo "==> Building initial binaries" | ||
cd $(go env GOPATH)/src/github.com/dotStart/Stockpile | ||
make | ||
cp -R $(go env GOPATH)/src/github.com/dotStart/Stockpile/build/linux-amd64 /opt/stockpile | ||
SHELL | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/* | ||
* Copyright 2018 Johannes Donath <[email protected]> | ||
* and other copyright owners as documented in the project's IP log. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package client | ||
|
||
import ( | ||
"context" | ||
"io" | ||
|
||
"github.com/dotStart/Stockpile/entity" | ||
"github.com/dotStart/Stockpile/rpc" | ||
"github.com/golang/protobuf/ptypes/empty" | ||
) | ||
|
||
// provides an alias for a function which's sole purpose is to respond to error cases in async | ||
// functions | ||
type ErrorFunc = func(error) | ||
|
||
// creates an event channel which will be notified about cache events as they occur | ||
func (s *Stockpile) EventChannel(errorHandler ErrorFunc) (chan *entity.Event, error) { | ||
eventClient, err := s.eventService.StreamEvents(context.Background(), &empty.Empty{}) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
outputChannel := make(chan *entity.Event) | ||
go func() { | ||
for true { | ||
evt, err := eventClient.Recv() | ||
if err != nil { | ||
if err == io.EOF { | ||
return | ||
} | ||
|
||
s.Logger.Printf("Failed to poll for events: %s", err) | ||
if errorHandler != nil { | ||
errorHandler(err) | ||
} | ||
return | ||
} | ||
|
||
parsed, err := rpc.EventFromRpc(evt) | ||
if err != nil { | ||
s.Logger.Printf("Failed to decode event: %s", err) | ||
continue | ||
} | ||
|
||
outputChannel <- parsed | ||
} | ||
}() | ||
return outputChannel, nil | ||
} |
Oops, something went wrong.