rename apid -> apid-core
diff --git a/.travis.yml b/.travis.yml index d0e1a77..a902a1c 100644 --- a/.travis.yml +++ b/.travis.yml
@@ -10,7 +10,6 @@ install: - glide install - - cd cmd/apid ; glide install script: - go test $(glide novendor)
diff --git a/README.md b/README.md index e98b25e..e3519f2 100644 --- a/README.md +++ b/README.md
@@ -1,38 +1,11 @@ -# APID +# apid-core -Apid is a container for publishing APIs that provides core services to its plugins including configuration, -API publishing, data access, and a local pub/sub event system. +apid-core is a library that provides a container for publishing APIs that provides core services to its plugins +including configuration, API publishing, data access, and a local pub/sub event system. -## To build and run standalone +Disambiguation: You might be looking for the executable builder, [apid](https://github.com/30x/apid). - cd cmd/apid - glide install - go build - ./apid - -For command line options: - - ./apid -help - -# Configuration - -Configuration can be done via yaml file or environment variables. Keys are case-insensitive. -By default, apid will look for a file called apid_config.yaml in the current working directory. - -#### Environment variables - -Config will pick up env vars automatically. Use "apid_" as a prefix for settings. For example, for apid's "log_level" -configuration setting, set env var "apid_log_level". - -### Defaults - - api_port: 9000 - api_expvar_path: nil # not exposed - data_path: /var/tmp - events_buffer_size: 5 - log_level: debug # valid values: Debug, Info, Warning, Error, Fatal, Panic - -# Services +## Services apid provides the following services: @@ -54,7 +27,7 @@ Once apid.Initialize() has been called, all services are accessible via the apid package functions as details above. -# Plugins +## Plugins The only requirement of an apid plugin is to register itself upon init(). However, generally plugins will access the Log service and some kind of driver (via API or Events), so it's common practice to see something like this: @@ -76,23 +49,6 @@ // respond to request } -# Helpful Hints +## Running Tests -* Use `export APID_DATA_TRACE_LOG_LEVEL=debug` to see DB Tracing - -### Glide -still here is what we need to do to have glide working correctly: -+ make sure `$GOPATH/pkg` `$GOPATH/bin` dirs are empty -+ each project should have glide.yaml with version - -``` -- package: github.com/gorilla/mux - version: v1.3.0 -- package: github.com/spf13/viper - version: 5ed0fc31f7f453625df314d8e66b9791e8d13003 -``` - -+ all projects we have should have same versions reference -+ glide.lock file must be checked in once and updated only on new dependency version update -+ you never do `glide up` anymore always do `glide i`. Do `glide up` only when there is new dependency version update -+ all CI jobs do only `glide install` + go test $(glide novendor)
diff --git a/api/api.go b/api/api.go index bc98f61..6af1b7f 100644 --- a/api/api.go +++ b/api/api.go
@@ -1,7 +1,7 @@ package api import ( - "github.com/30x/apid" + "github.com/30x/apid-core" "github.com/gorilla/mux" "net/http" "expvar"
diff --git a/api/api_suite_test.go b/api/api_suite_test.go index 8a93089..d724826 100644 --- a/api/api_suite_test.go +++ b/api/api_suite_test.go
@@ -8,8 +8,8 @@ ) import ( - "github.com/30x/apid" - "github.com/30x/apid/factory" + "github.com/30x/apid-core" + "github.com/30x/apid-core/factory" "net/http/httptest" "os" )
diff --git a/cmd/apid/README.md b/cmd/apid/README.md deleted file mode 100644 index fa1d512..0000000 --- a/cmd/apid/README.md +++ /dev/null
@@ -1,19 +0,0 @@ -# cmd/apid - -## Core plugins -* [ApigeeSync](https://github.com/30x/apidApigeeSync) -* [VerifyAPIKey](https://github.com/30x/apidVerifyApiKey) -* [GatewayDeploy](https://github.com/30x/apidGatewayDeploy) -* [ApigeeAnalytics](https://github.com/30x/apidAnalytics) - -To change plugins list, edit main.go and update glide.yaml. - -## Build and execute - - glide install - go build - ./apid - -For options: - - ./apid -help
diff --git a/cmd/apid/apid_config_sample.yaml b/cmd/apid/apid_config_sample.yaml deleted file mode 100644 index a524b28..0000000 --- a/cmd/apid/apid_config_sample.yaml +++ /dev/null
@@ -1,12 +0,0 @@ -api_port: 9090 -api_expvar_path: nil # not exposed -events_buffer_size: 5 -log_level: debug # valid values: Debug, Info, Warning, Error, Fatal, Panic -apigeesync_proxy_server_base: http://local.com:9001/edgex -apigeesync_snapshot_server_base: http://local.com:9001/edgex -apigeesync_change_server_base: http://local.com:9001/edgex -apigeesync_snapshot_proto: json -apigeesync_consumer_key: MDygyE8OD8rlemI7S1XhlUCA7jrarjxl -apigeesync_consumer_secret: oAuKUqRVvFVq0tzS -apigeesync_cluster_id: fc0e5137-d3fa-4017-8bfa-86b1103bc85d -apidanalytics_uap_server_base: http://local.com:9001/edgex \ No newline at end of file
diff --git a/cmd/apid/glide.yaml b/cmd/apid/glide.yaml deleted file mode 100644 index cd7c376..0000000 --- a/cmd/apid/glide.yaml +++ /dev/null
@@ -1,12 +0,0 @@ -package: github.com/30x/apid/cmd/apid -import: -- package: github.com/30x/apid - version: master -- package: github.com/30x/apidApigeeSync - version: master -- package: github.com/30x/apidGatewayDeploy - version: master -- package: github.com/30x/apidVerifyAPIKey - version: master -- package: github.com/30x/apidAnalytics - version: master
diff --git a/cmd/apid/main.go b/cmd/apid/main.go deleted file mode 100644 index 69c0e05..0000000 --- a/cmd/apid/main.go +++ /dev/null
@@ -1,57 +0,0 @@ -package main - -import ( - // import plugins to ensure they're bound into the executable - _ "github.com/30x/apidAnalytics" - _ "github.com/30x/apidApigeeSync" - _ "github.com/30x/apidGatewayDeploy" - _ "github.com/30x/apidVerifyAPIKey" - - // other imports - "flag" - "os" - - "github.com/30x/apid" - "github.com/30x/apid/factory" -) - -func main() { - configFlag := flag.String("config", "", "path to the yaml config file [./apid_config.yaml]") - cleanFlag := flag.Bool("clean", false, "start clean, deletes all existing data from local_storage_path") - - configFile := *configFlag - if configFile != "" { - os.Setenv("APID_CONFIG_FILE", configFile) - } - - flag.Parse() - - apid.Initialize(factory.DefaultServicesFactory()) - - log := apid.Log() - config := apid.Config() - - if *cleanFlag { - localStorage := config.GetString("local_storage_path") - log.Infof("removing existing data from: %s", localStorage) - if err := os.RemoveAll(localStorage); err != nil { - log.Panicf("Failed to clean data directory: %v", err) - } - if err := os.MkdirAll(localStorage, 0700); err != nil { - log.Panicf("can't create local storage path %s:%v", localStorage, err) - } - } - - log.Debug("initializing...") - - apid.InitializePlugins() - - // start client API listener - log.Debug("listening...") - - api := apid.API() - err := api.Listen() - if err != nil { - log.Print(err) - } -}
diff --git a/config/config.go b/config/config.go index 87ee486..9fe19a4 100644 --- a/config/config.go +++ b/config/config.go
@@ -1,7 +1,7 @@ package config import ( - "github.com/30x/apid" + "github.com/30x/apid-core" "github.com/spf13/viper" "log" "strings"
diff --git a/data/data.go b/data/data.go index a886daa..b6d9cbd 100644 --- a/data/data.go +++ b/data/data.go
@@ -3,8 +3,8 @@ import ( "database/sql" "fmt" - "github.com/30x/apid" - "github.com/30x/apid/data/wrap" + "github.com/30x/apid-core" + "github.com/30x/apid-core/data/wrap" "github.com/mattn/go-sqlite3" "os" "path"
diff --git a/data/data_suite_test.go b/data/data_suite_test.go index 0daef56..eba39e0 100644 --- a/data/data_suite_test.go +++ b/data/data_suite_test.go
@@ -5,8 +5,8 @@ . "github.com/onsi/gomega" "testing" - "github.com/30x/apid" - "github.com/30x/apid/factory" + "github.com/30x/apid-core" + "github.com/30x/apid-core/factory" "io/ioutil" "os" )
diff --git a/data/data_test.go b/data/data_test.go index 85e6110..c2546db 100644 --- a/data/data_test.go +++ b/data/data_test.go
@@ -2,14 +2,14 @@ import ( "fmt" - "github.com/30x/apid" + "github.com/30x/apid-core" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" "log" "math/rand" "strconv" "time" - "github.com/30x/apid/data" + "github.com/30x/apid-core/data" "database/sql" )
diff --git a/data/wrap/connection.go b/data/wrap/connection.go index 46d04a3..bd865b3 100644 --- a/data/wrap/connection.go +++ b/data/wrap/connection.go
@@ -1,7 +1,7 @@ package wrap import ( - "github.com/30x/apid" + "github.com/30x/apid-core" "github.com/mattn/go-sqlite3" "database/sql/driver" )
diff --git a/data/wrap/driver.go b/data/wrap/driver.go index f1095dd..62a799a 100644 --- a/data/wrap/driver.go +++ b/data/wrap/driver.go
@@ -3,7 +3,7 @@ import ( "database/sql/driver" "strings" - "github.com/30x/apid" + "github.com/30x/apid-core" "github.com/mattn/go-sqlite3" )
diff --git a/data/wrap/statement.go b/data/wrap/statement.go index ba440f6..1176aee 100644 --- a/data/wrap/statement.go +++ b/data/wrap/statement.go
@@ -2,7 +2,7 @@ import ( "database/sql/driver" - "github.com/30x/apid" + "github.com/30x/apid-core" "github.com/mattn/go-sqlite3" )
diff --git a/data/wrap/transaction.go b/data/wrap/transaction.go index 5947581..bd6fa25 100644 --- a/data/wrap/transaction.go +++ b/data/wrap/transaction.go
@@ -1,7 +1,7 @@ package wrap import ( - "github.com/30x/apid" + "github.com/30x/apid-core" "github.com/mattn/go-sqlite3" )
diff --git a/events/event_manager.go b/events/event_manager.go index 949c705..33b0ee1 100644 --- a/events/event_manager.go +++ b/events/event_manager.go
@@ -1,7 +1,7 @@ package events import ( - "github.com/30x/apid" + "github.com/30x/apid-core" "sync" )
diff --git a/events/events.go b/events/events.go index d48fcd7..f2f0839 100644 --- a/events/events.go +++ b/events/events.go
@@ -1,6 +1,6 @@ package events -import "github.com/30x/apid" +import "github.com/30x/apid-core" // simple pub/sub to deliver events to listeners based on a selector string
diff --git a/events/events_suite_test.go b/events/events_suite_test.go index 478c54d..2299af4 100644 --- a/events/events_suite_test.go +++ b/events/events_suite_test.go
@@ -5,8 +5,8 @@ . "github.com/onsi/gomega" "testing" - "github.com/30x/apid" - "github.com/30x/apid/factory" + "github.com/30x/apid-core" + "github.com/30x/apid-core/factory" ) var _ = BeforeSuite(func() {
diff --git a/events/events_test.go b/events/events_test.go index 804d1f9..70bc19a 100644 --- a/events/events_test.go +++ b/events/events_test.go
@@ -1,8 +1,8 @@ package events_test import ( - "github.com/30x/apid" - "github.com/30x/apid/events" + "github.com/30x/apid-core" + "github.com/30x/apid-core/events" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" "sync/atomic"
diff --git a/factory/factory.go b/factory/factory.go index 7a94b83..d270e75 100644 --- a/factory/factory.go +++ b/factory/factory.go
@@ -1,12 +1,12 @@ package factory import ( - "github.com/30x/apid" - "github.com/30x/apid/api" - "github.com/30x/apid/config" - "github.com/30x/apid/data" - "github.com/30x/apid/events" - "github.com/30x/apid/logger" + "github.com/30x/apid-core" + "github.com/30x/apid-core/api" + "github.com/30x/apid-core/config" + "github.com/30x/apid-core/data" + "github.com/30x/apid-core/events" + "github.com/30x/apid-core/logger" ) // Don't use values directly - pass to apid.Initialize()
diff --git a/load-test/Dockerfile b/load-test/Dockerfile deleted file mode 100644 index 392d0d1..0000000 --- a/load-test/Dockerfile +++ /dev/null
@@ -1,27 +0,0 @@ -FROM golang:1.7-wheezy - -# install tools -RUN apt-get update && apt-get -y install vim sqlite3 && curl https://glide.sh/get | sh - -RUN mkdir -p /demo/data -WORKDIR /go/src/github.com/30x - -# install apid -RUN git clone https://github.com/30x/apid.git \ - && (cd apid/cmd/apid; glide install) \ - && (cd apid/cmd/apid; go build) \ - && cp apid/cmd/apid/apid /demo - -# install mock server -RUN (git clone https://github.com/30x/apidApigeeSync.git) \ - && (cd apidApigeeSync/; glide install) \ - && (cd apidApigeeSync/cmd/mockServer; go build) \ - && cp apidApigeeSync/cmd/mockServer/mockServer /demo - -WORKDIR /demo -COPY ./apid_config.yaml apid_config.yaml -COPY ./startServices.sh startServices.sh - -CMD startServices.sh - -EXPOSE 9000
diff --git a/load-test/README.md b/load-test/README.md deleted file mode 100644 index cac88eb..0000000 --- a/load-test/README.md +++ /dev/null
@@ -1,13 +0,0 @@ -# Docker build for load testing - -## Build - - docker build . - -## Run - -docker will open port 9000 for api hits - -## Start the load -+ Install https://artillery.io/ -+ `artillery run artillery/deployment.yaml ` \ No newline at end of file
diff --git a/load-test/apid_config.yaml b/load-test/apid_config.yaml deleted file mode 100644 index 4911a1c..0000000 --- a/load-test/apid_config.yaml +++ /dev/null
@@ -1,14 +0,0 @@ -api_port: 9000 -api_expvar_path: /expvar -events_buffer_size: 5 -apigeesync_proxy_server_base: http://localhost:9001 -apigeesync_snapshot_server_base: http://localhost:9001 -apigeesync_change_server_base: http://localhost:9001 -apidanalytics_uap_server_base: http://localhost:9001 -apigeesync_consumer_key: key -apigeesync_consumer_secret: secret -apigeesync_cluster_id: cluster -log_level: info -data_trace_log_level: info -data_source: file:%s?_busy_timeout=20000 -local_storage_path: /demo/data
diff --git a/load-test/artillery/deployment.yaml b/load-test/artillery/deployment.yaml deleted file mode 100644 index d108142..0000000 --- a/load-test/artillery/deployment.yaml +++ /dev/null
@@ -1,26 +0,0 @@ -config: - target: 'http://localhost:9090' - http: - timeout: 10 - phases: - - duration: 120 - arrivalRate: 1 - processor: "./my-functions.js" - defaults: - headers: - x-my-service-auth: '987401838271002188298567' - -scenarios: - - - name: "Deployments ping" - flow: - - - get: - url: "/deployments" - afterResponse: "captureDeployments" - - - think: 1 - - - put: - url: "/deployments" - beforeRequest: "fakeStatuses"
diff --git a/load-test/artillery/my-functions.js b/load-test/artillery/my-functions.js deleted file mode 100644 index aa93abe..0000000 --- a/load-test/artillery/my-functions.js +++ /dev/null
@@ -1,38 +0,0 @@ -// -// my-functions.js -// -module.exports = { - captureDeployments: captureDeployments, - fakeStatuses: fakeStatuses -} - -function captureDeployments(requestParams, response, context, ee, next) { - - var array = JSON.parse(response.body); - context.vars.captureDeployments = array; - return next(); // MUST be called for the scenario to continue -} -/* - requestParam are the parameters from this list - https://github.com/request/request#requestoptions-callback -*/ -function fakeStatuses(requestParams, context, ee, next) { - //console.log("--------------------------"); - //console.log(context.vars.captureDeployments) - var d = context.vars.captureDeployments; - var statusArray = []; - - for (var i = 0; i< d.length; i++) { - var status = { - "id":d[i].id, - "status": (i>(d.length*0.1))?"FAIL":"SUCCESS", - "message": "Some random message long.Some random message long.Some random message long.Some random message long.Some random message long.Some random message long.Some random message long.", - "errorCode":1 - }; - statusArray.push(status); - } - requestParams.body = statusArray; - requestParams.json = true; - //console.log(requestParams.body); - return next();// MUST be called for the scenario to continue -} \ No newline at end of file
diff --git a/load-test/artillery/users.yaml b/load-test/artillery/users.yaml deleted file mode 100644 index bc2d1f2..0000000 --- a/load-test/artillery/users.yaml +++ /dev/null
@@ -1,72 +0,0 @@ -config: - target: http://localhost:9000 - http: - timeout: 10 - phases: - - duration: 120 - arrivalRate: 50 - defaults: - headers: {} - -scenarios: - - name: "Verified user" - flow: - - post: - headers: - Content-Type: application/x-www-form-urlencoded - url: /verifiers/apikey - body: "action=verify&key=1&uriPath=/&scopeuuid=scope" - - post: - url: /analytics/scope - json: - records: - - apiproxy: default - apiproxy_revision: "15" - client_ip: "::1" - client_received_start_timestamp: 1486591233123 - client_received_end_timestamp: 1486591233130 - client_sent_start_timestamp: 1486591233327 - client_sent_end_timestamp: 1486591233330 - request_path: /iloveapis - request_uri: http://localhost:8000/iloveapis - request_verb: GET - response_status_code: 200 - useragent: curl/7.43.0 - target_received_end_timestamp: 1486591233130 - target_received_start_timestamp: 1486591233130 - target_response_code: 200 - target_sent_end_timestamp: 1486591233327 - target_sent_start_timestamp: 1486591233328 - target: default - recordType: APIAnalytics - - - name: "Unverified user" - flow: - - post: - headers: - Content-Type: application/x-www-form-urlencoded - url: /verifiers/apikey - body: "action=verify&key=99999&uriPath=/&scopeuuid=scope" - - post: - url: /analytics/scope - json: - records: - - apiproxy: default - apiproxy_revision: "15" - client_ip: "::1" - client_received_start_timestamp: 1486591233123 - client_received_end_timestamp: 1486591233130 - client_sent_start_timestamp: 1486591233327 - client_sent_end_timestamp: 1486591233330 - request_path: /iloveapis - request_uri: http://localhost:8000/iloveapis - request_verb: GET - response_status_code: 200 - useragent: curl/7.43.0 - target_received_end_timestamp: 1486591233130 - target_received_start_timestamp: 1486591233130 - target_response_code: 200 - target_sent_end_timestamp: 1486591233327 - target_sent_start_timestamp: 1486591233328 - target: default - recordType: APIAnalytics
diff --git a/load-test/startServices.sh b/load-test/startServices.sh deleted file mode 100755 index 1e4ac6c..0000000 --- a/load-test/startServices.sh +++ /dev/null
@@ -1,11 +0,0 @@ -#!/bin/bash - -cd /demo - -echo "----- Apid config being loaded -----" -cat apid_config.yaml -echo "--------- End apid config ----------" - -APID_API_PORT=9001 ./mockServer -numDeps=100 -numDevs=50000 -addDevEach=3s -upDevEach=1s -upDepEach=3s & -sleep 2 -./apid -clean &
diff --git a/logger/logger.go b/logger/logger.go index 9489195..edd1afa 100644 --- a/logger/logger.go +++ b/logger/logger.go
@@ -5,7 +5,7 @@ "os" "time" - "github.com/30x/apid" + "github.com/30x/apid-core" "github.com/Sirupsen/logrus" )
diff --git a/tools/internal_ci/README.md b/tools/internal_ci/README.md deleted file mode 100644 index c6affca..0000000 --- a/tools/internal_ci/README.md +++ /dev/null
@@ -1,4 +0,0 @@ -# SCM - -This file contains some scripts and configuration files for use with an -internal CI system.
diff --git a/tools/internal_ci/linux/apid_continuous.cfg b/tools/internal_ci/linux/apid_continuous.cfg deleted file mode 100644 index ac4e6c5..0000000 --- a/tools/internal_ci/linux/apid_continuous.cfg +++ /dev/null
@@ -1,3 +0,0 @@ -build_file: "apid/tools/internal_ci/linux/test.sh" -timeout_mins: 30 -
diff --git a/tools/internal_ci/linux/apid_release.cfg b/tools/internal_ci/linux/apid_release.cfg deleted file mode 100644 index 9734f81..0000000 --- a/tools/internal_ci/linux/apid_release.cfg +++ /dev/null
@@ -1,7 +0,0 @@ -build_file: "apid/tools/internal_ci/linux/build.sh" -timeout_mins: 30 -action { - define_artifacts { - regex: "apid" - } -}
diff --git a/tools/internal_ci/linux/build.sh b/tools/internal_ci/linux/build.sh deleted file mode 100755 index 70b6d4e..0000000 --- a/tools/internal_ci/linux/build.sh +++ /dev/null
@@ -1,27 +0,0 @@ -#!/bin/bash - -BUILDROOT=${BUILDROOT:-git/apid} -export BUILDROOT - -# Make a temporary GOPATH to build in -gobase=`mktemp -d` -GOPATH=${gobase} -export GOPATH - -go get github.com/Masterminds/glide - -base=${gobase}/src/github.com/30x/apid -mkdir -p ${base} -(cd ${BUILDROOT}; tar cf - .) | (cd ${base}; tar xf -) - -set +x - -(cd ${base}; ${GOPATH}/bin/glide install) -(cd ${base}; go build -o apid ./cmd/apid) -buildResult=$? - -cp ${base}/apid . - -rm -rf ${gobase} - -exit ${buildResult}
diff --git a/tools/internal_ci/linux/test.sh b/tools/internal_ci/linux/test.sh deleted file mode 100755 index 3d9df27..0000000 --- a/tools/internal_ci/linux/test.sh +++ /dev/null
@@ -1,30 +0,0 @@ -#!/bin/bash - -BUILDROOT=${BUILDROOT:-git/apid} -export BUILDROOT - -# Make a temporary GOPATH to build in -gobase=`mktemp -d` -GOPATH=${gobase} -export GOPATH - -go get github.com/Masterminds/glide - -base=${gobase}/src/github.com/30x/apid -mkdir -p ${base} -(cd ${BUILDROOT}; tar cf - .) | (cd ${base}; tar xf -) - -(cd ${base}; ${GOPATH}/bin/glide install) -(cd ${base}; go test ./api ./config ./events ./factory ./logger) -testResult=$? - -if [ $testResult -eq 0 ] -then - echo "Building apid binary" - (cd ${base}; go build ./cmd/apid) - testResult=$? -fi - -rm -rf ${gobase} - -exit ${testResult}