Coder Social home page Coder Social logo

sleepy-server's Introduction

Issues ๐Ÿ”ธ Documentation ๐Ÿ”ธ Releases

A Sleepy Software Testing Utility

GitHub issues Last Commit MIT

Elapsed Project Time

wakatime

If you like this repository, please give it a โญ (it really does help)

GitHub repository stars

The Sleepy Server is a simple software testing utility. The server will sleep for the period specified in the incoming request before it responds.

The only API method takes a single parameter:

http(s)://sleepy.server.org/:sleepValue

Where :sleepValue determines the period that the server will wait before sending a response.

The length of the delay is calculated as the :sleepValue multiplied by the valueMultiplier environment variable (which defaults to 1000 - and as such, we can say that the length of the delay is counted in milliseconds)

Docker Image

Use the 'standard' method to launch the Docker Image from the root directory of the project:

docker build -t sleepy:test .

Examples

Example #1

With a :sleepValue of 5 (and the default multiplyer = 1000)

$ date; time http http://localhost:3000/5 -b; date
Wed Nov 16 09:02:02 CET 2022
Woke up after 5 second(s) of sleep!
...  0.35s user 0.15s system 8% cpu 5.655 total
Wed Nov 16 09:02:08 CET 2022

In your terminal window, the scenario might play out like this:

$ docker run --rm -p 3000:3000 -d sleepy:test
$ docker logs -tf agitated_elemental
2022-11-16T08:00:23.621848495Z Sleeping server listening on port 3000
2022-11-16T08:02:03.494774343Z Going to sleep for 5 second(s)!
2022-11-16T08:02:08.498342553Z Wake up! 5 second(s) passed.

Example #2

Simultaneous Requests:

$ date; for I in $(seq 5 -2 1); do \
		((http GET http://localhost:3000/$I -b | cat - && echo -n ' -- ' && date) &) \
	done
		
Wed Nov 16 09:03:47 CET 2022
Woke up after 1 second(s) of sleep! -- Wed Nov 16 09:03:48 CET 2022
Woke up after 3 second(s) of sleep! -- Wed Nov 16 09:03:50 CET 2022
Woke up after 5 second(s) of sleep! -- Wed Nov 16 09:03:52 CET 2022

And in the server logs:

2022-11-16T08:03:47.917399749Z Going to sleep for 5 second(s)!
2022-11-16T08:03:47.923730533Z Going to sleep for 1 second(s)!
2022-11-16T08:03:47.924537943Z Going to sleep for 3 second(s)!
2022-11-16T08:03:48.925443668Z Wake up! 1 second(s) passed.
2022-11-16T08:03:50.925969532Z Wake up! 3 second(s) passed.
2022-11-16T08:03:52.918711537Z Wake up! 5 second(s) passed.

Configuration (Environment Variables)

  • port - the port on the server will be listening on
  • valueMultiplier - the multiplier of :sleepValue which is used to calculate the length of the delay before the server responds. Leaving this value set to the default of 1000 makes :sleepValue roughly equal to a number of seconds.

Project Resources:

Community Resources

^ Top

โค๏ธ Project Supporters

JetBrains

JetBrains very generously provide me with a free license for their products every month, and you can get one too if you're working on a public, open-source project! I've used JetBrains' IDEs for many years now, and was more than happy to pay for a license every year back when I was working in the corporate sector. Absolutely my first choice in IDEs!

If sponsorship isn't right for you, but you have found my work to be useful in some way,
would you please consider buying me a coffee to help keep me going?

Buy Me A Coffee

^ Top

^ Top

๐Ÿ” Security

While I always good security practices, 100% security can never be guaranteed in any software package. The Sleepy Server is provided AS IS, and without warranty. You can find more details in the LICENSE file included with this repository.

If you discover any issue regarding the security of this project, please disclose that information responsibly by sending a security advisory. PLEASE DO NOT CREATE AN ISSUE OR DISCUSSION TOPIC. You can read more about this project's security policies HERE

^ Top

This project incorporates ideas and / or code crafted by the following talented individuals:

"We see much further, and reach much higher,
only because we stand upon the shoulders of giants"

^ Top

โš–๏ธ License

MIT

Copyright ยฉ 2023 Darren (Ragdata) Poulton

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

^ Top

๐Ÿ“– Resources

^ Top

If you like this repository, please give it a โญ (it really does help)

GitHub repository stars

Visitors Ragdata

sleepy-server's People

Contributors

ragdata avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.