mnemosyne

package module
v0.14.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 9, 2017 License: MIT Imports: 5 Imported by: 0

README

Mnemosyne Build Status

GoDoc Docker Pulls codecov.io Code Climate pypi

Introduction

Mnemosyne is an open-source self-hosted session management service. It's written in Go, making it easy to build and deploy as a static binary.

It provides gRPC interface. Messages are encoded using protobuf.

Quick Start

To install and run service:

$ go get -d github.com/piotrkowalczuk/mnemosyne/...
$ cd $GOPATH/src/github.com/piotrkowalczuk/mnemosyne
$ make
$ mnemosyned -log.environment=development -postgres.address='postgres://localhost/example?sslmode=disable'
Examples
Go
package main

import (
	"fmt"

	"golang.org/x/net/context"
	"github.com/piotrkowalczuk/mnemosyne"
)

func main() {
	mnemo, err := mnemosyne.New(mnemosyne.MnemosyneOpts{
		Addresses: []string{"127.0.0.1:8080"},
		Block: true,
	})
	if err != nil {
		// ...
	}
	defer mnemo.Close()

	ses, err := mnemo.Start(context.Background(), "subject-id", "subject-client", map[string]string{
		"username": "johnsnow@gmail.com",
		"first_name": "John",
		"last_name": "Snow",
	})
	if err != nil {
		// ...
	}

	fmt.Println(ses.AccessToken)
}
Python

Library is available through pypi and can be installed by typing pip install mnemosyne-client.

from  mnemosynerpc import session_pb2, session_pb2_grpc
import grpc


channel = grpc.insecure_channel('localhost:8080')
stub = session_pb2_grpc.SessionManagerStub(channel)

for i in range(0, 10):
	res = stub.Start(session_pb2.StartRequest(session=session_pb2.Session(subject_id=str(i))))

	res = stub.Get(session_pb2.GetRequest(access_token=res.session.access_token))
	print "%s - %s" % (res.session.access_token, res.session.expire_at.ToJsonString())
Storage Engine

Goal is to support multiple storage's, like PostgreSQL, Redis or MongoDB. Nevertheless currently supported is only PostgreSQL.

Remote Procedure Call API

For communication, Mnemosyne is exposing RPC API that uses protocol buffers, Google’s mature open source mechanism for serializing structured data.

  • Create
  • Get
  • List
  • Exists
  • Abandon
  • SetData
  • Delete

Installation

Mnemosyne can be installed in one way, from source. Or can be used as a container using docker image.

From source

To install from source both go tools and glide is required.

$ go get -d github.com/piotrkowalczuk/mnemosyne/...
$ cd $GOPATH/src/github.com/piotrkowalczuk/mnemosyne
$ make
Configuration

mnemosyned accepts command line arguments to control its behavior. Possible options are is listed below.

Name Flag Default Type
host -host 127.0.0.1 string
port -port 8080 int
cluster listen address -cluster.listen string
cluster seeds -cluster.seeds string
time to live -ttl 24m duration
time to clear -ttc 1m duration
logger environment -log.environment production enum(development, production, stackdriver)
logger level -log.level info enum(debug, info, warn, error, dpanic, panic, fatal)
monitoring -monitoring false boolean
storage -storage postgres enum(postgres)
postgres address -postgres.address postgres://postgres:postgres@postgres/postgres?sslmode=disable string
postgres table -postgres.table session string
postgres schema -postgres.schema mnemosyne string
tls -tls false boolean
tls certificate file -tls.crt string
tls key file -tls.key string
Running

As we know, mnemosyne can be configured in many ways. For the beginning we can start simple:

$ mnemosyned postgres.address="postgres://localhost/test?sslmode=disable"

Mnemosyne will automatically create all required tables/indexes for specified database.

Contribution

TODO
  • Client library
    • Go
    • Python
  • Engines
    • PostgreSQL
      • Get
      • List
      • Exists
      • Create
      • Abandon
      • SetData
      • Delete
      • Setup
      • TearDown
    • RAM
    • Redis

Documentation

Index

Constants

View Source
const (
	// AccessTokenMetadataKey is used by Mnemosyne to retrieve session token from gRPC metadata object.
	AccessTokenMetadataKey = "authorization"
)

Variables

This section is empty.

Functions

func AccessTokenFromContext added in v0.5.0

func AccessTokenFromContext(ctx context.Context) (string, bool)

AccessTokenFromContext returns the token value stored in context, if any.

func NewAccessTokenContext added in v0.5.0

func NewAccessTokenContext(ctx context.Context, at string) context.Context

NewAccessTokenContext returns a new Context that carries token value.

func RandomAccessToken added in v0.5.0

func RandomAccessToken() (string, error)

RandomAccessToken generate Access Token with given key and generated hash of length 64.

Types

This section is empty.

Directories

Path Synopsis
cmd
internal
discovery
Package discovery is under development.
Package discovery is under development.
storage/storagemock
Code generated by mockery v1.0.0 Code generated by mockery v1.0.0
Code generated by mockery v1.0.0 Code generated by mockery v1.0.0
Package mnemosynerpc is a generated protocol buffer package.
Package mnemosynerpc is a generated protocol buffer package.
Code generated by mockery v1.0.0 Code generated by mockery v1.0.0
Code generated by mockery v1.0.0 Code generated by mockery v1.0.0

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL