Skip to content

Keep your root application running cool by cloning your current application for potentially risky operations.

License

Notifications You must be signed in to change notification settings

AlexanderMann/ac

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ac

      _                   __    ___
 ___ /|\ = ~ - ~   -   ~ / _\  / __)
|___|-o-| = - ~ - -   ~ /    \( (__
 ||  \|/ = ~ ~ - ~   .  \_/\_/ \___)
 /\

Keep your root application running cool by running functions in a separate JVM.

Usage

Clojars Project Circle CI

(ns demo
  (:require [me.alxmnn.ac :as ac]))

; First we declare some function where we care about the
; side effects, but know there's a chance that it could run
; out of memory. A great example is reading TEXT fields from
; a PostgreSQL DB. Those fields are potentially 4GB in size,
; which can be too much to safely handle.
(defn use-all-the-memory!
  [period1 period2 period3]
  (apply str (repeat (str period1 period2 period3))))

; We create a standalone process which will run our
; fully-qualified fn from above in a separate JVM, protecting
; our current JVM from OOM.
(def p (ac/create-standalone-process 'demo/use-all-the-memory!
                                     "."
                                     "."
                                     "."))

; Let the process exit
(ac/wait-for-exit p)

; And we are still able to continue running our JVM even though
; we just "executed" code that causes an OOM.
(println (ac/error-message p))

License

Copyright © 2016 FIXME

Distributed under the Eclipse Public License either version 1.0 or (at your option) any later version.

About

Keep your root application running cool by cloning your current application for potentially risky operations.

Resources

License

Stars

Watchers

Forks

Packages

No packages published