Skip to content

Commit

Permalink
upgrade to FastFaker 2.0 and removed the old code
Browse files Browse the repository at this point in the history
  • Loading branch information
bgadrian committed Nov 19, 2018
1 parent c727d62 commit e41d6c0
Show file tree
Hide file tree
Showing 14 changed files with 37 additions and 528 deletions.
115 changes: 0 additions & 115 deletions CUSTOM.md

This file was deleted.

2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ RUN go mod download
COPY . .
RUN make build

FROM scratch
FROM alpine
COPY --from=builder /src/build/pseudoservice .
ENV PORT=8080
EXPOSE 8080
Expand Down
53 changes: 0 additions & 53 deletions LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -619,56 +619,3 @@ Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.

END OF TERMS AND CONDITIONS

How to Apply These Terms to Your New Programs

If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.

To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.

<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.

Also add information on how to contact you by electronic and paper mail.

If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:

<program> Copyright (C) <year> <name of author>
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.

The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".

You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
<https://www.gnu.org/licenses/>.

The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
<https://www.gnu.org/licenses/why-not-lgpl.html>.
5 changes: 1 addition & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@ pre:
env GO111MODULE=on go get -d ./
env GO111MODULE=on go test -race ./...

generate:
go run cmd/custom-key-generator/main.go go > handlers/custom_keys.go
go run cmd/custom-key-generator/main.go mark > CUSTOM.md

run: pre
env PORT=8080 go run $(source)

Expand All @@ -19,6 +15,7 @@ build: pre
@echo "See ./build/pseudoservice --help"

buildall: pre
rm -f ./build/pseudoservice
mkdir -p ./build/pseudoservice/windows
mkdir -p ./build/pseudoservice/linux
mkdir -p ./build/pseudoservice/macos
Expand Down
20 changes: 11 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
# Pseudo service ![travis-mater](https://travis-ci.com/bgadrian/pseudoservice.svg?branch=master) [![Go Report Card](https://goreportcard.com/badge/github.com/bgadrian/pseudoservice)](https://goreportcard.com/report/github.com/bgadrian/pseudoservice)

Pseudo random (deterministic) data generator as a (micro) service.
It is a wrapper for the [FastFaker Go package](https://github.com/bgadrian/fastfaker).

#### The problem
The need to generate random (user or other type) data, to (stress) test your own system.
The need to generate random (user or other type) data, to mockup, test or stress your own systems.

#### The solution
I've built this project to be used as an internal service, to generate large amounts of fake data.

It was originally built for this project: [davidescus/10minFor300Gb](https://github.com/davidescus/10minFor300Gb) as a wrapper on [bgadrian/fastfaker](https://github.com/bgadrian/gofakeit).

### Performance

On my localhost (4 Core 3Ghz) I was able to generate over **14.000 users/second** (`/users/`) with 100 batches, on an 600Mhz B2 AppEngine (1 Core) can deliver 900 users/second.
Expand All @@ -22,7 +21,7 @@ For the best performance:

### How it works

You run it as a simple HTTP server, in a private network, and clients can make requests to get random data.
You run it as a simple HTTP server, in a private network, and the clients can make requests to get random data, based on their custom templates/needs.

Global optional parameters:
* `?seed=42` - if given, the result will be deterministic, as in for all calls the same data will be returned.
Expand All @@ -40,7 +39,7 @@ Returns `200` if the service is available.
##### /custom/{count}?template="Hello &#126;name&#126;!"
Generate random data based on a given template. Supports any string, including JSON schema.

The template can contains variables like `~name~` or `~email~`.
The template can contains variables like `~name~` or `~email~`. For a full list see the [FastFaker variables](https://github.com/bgadrian/fastfaker/blob/master/TEMPLATE_VARIABLES.md), but instead of `{}` you must use the `~` delimiter (it is more URL friendly).

```bash
#the template is URL encoded: Hello ~name~!
Expand Down Expand Up @@ -69,12 +68,15 @@ curl -X GET "http://localhost:8080/custom/6?token=SECRET42&seed=42&template=~cou
"Ethiopia",
"Afghanistan"
],"seed":42}

```
For all supported template variables see [CUSTOM.md](./CUSTOM.md)

For more examples see the FastFaker [examples](https://github.com/bgadrian/fastfaker/tree/master/example) and [GoDoc](https://godoc.org/github.com/bgadrian/fastfaker/faker#pkg-examples).

##### /users/{count}
Generate random users based on a preconfigured set of properties.
Generate random users based on a preconfigured set of properties, with a friend relationship between them.

This endpoint was created to simulate a Social network and test a Graph database: [davidescus/10minFor300Gb](https://github.com/davidescus/10minFor300Gb).

```bash
#fast and random user
curl "http://localhost:8080/api/v1/users/1?token=SECRET42"
Expand All @@ -90,7 +92,7 @@ curl "http://localhost:8080/api/v1/users/1?token=SECRET42"
}
]}

#slow and deterministic call (seed=42)
#slower but deterministic call (seed=42)
curl "http://localhost:8080/api/v1/users/1?token=SECRET42&seed=42"

{"seed":42,"nextseed":43,"users":[
Expand Down
Loading

0 comments on commit e41d6c0

Please sign in to comment.