Skip to content

RatchetWrench is a easily use Google Cloud Spanner by Elixir.

License

Notifications You must be signed in to change notification settings

hirocaster/ratchet_wrench

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RatchetWrench

RatchetWrench is a easily use Google Cloud Spanner by Elixir.

** This library production use in the mobile game. But does not fully support the "Google Cloud spanner" feature. **

Installation

If available in Hex, the package can be installed by adding ratchet_wrench to your list of dependencies in mix.exs:

def deps do
  [
    {:ratchet_wrench, "~> 0.4.0"}
  ]
end

Documentation can be generated with ExDoc and published on HexDocs. Once published, the docs can be found at https://hexdocs.pm/ratchet_wrench.

Setup

Credentials

Add GCP credentials json file path for env GOOGLE_APPLICATION_CREDENTIALS.

more detail's for goth.

Set Google Cloud Spanner config

Set database.

Add env RATCHET_WRENCH_DATABASE.

ex) "projects/projectname-123456/instances/your-instance/databases/your-db"

export RATCHET_WRENCH_DATABASE="projects/projectname-123456/instances/your-instance/databases/your-db"

or

Add config.exs

config :ratchet_wrench, database: "projects/projectname-123456/instances/your-instance/databases/your-db"

You must replace projectname-123456, your-instance, your-db.

Logging

Output for Logger module.

Add env RATCHET_WRENCH_ENABLE_LOGGING

export RATCHET_WRENCH_ENABLE_LOGGING=1

or

Add config.exs

config :ratchet_wrench, enable_logging: true

Migration

I recommend using wrench.

Usage

Sorry, will write sample more codes.

  • How to define model(Table) -> test/test_helper.exs
  • How to SELECT/INSERT/UPDATE -> test/ratchet_wrench/repo_test.exs

Setup config

Your application.ex write to example.

  def start(_type, _args) do
    children = [
    ...
      {RatchetWrench.SessionPool, %RatchetWrench.Pool{}}
    ]
    ...
  end

Shutdown

Cleanup session in Google Cloud Spanner at shutdown your app.

Process.send(RatchetWrench.SessionPool, :kill, [])

Support type in Google Cloud Spanner

  • STRING
  • DATE
  • BOOL
  • INT64
  • FLOAT64
  • TIMESTAMP

Unsupport types

  • ARRAY
  • BYTES
  • STRUCT

About

RatchetWrench is a easily use Google Cloud Spanner by Elixir.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages