Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Providing resources (simple MySQL implementation) #12

Closed
wants to merge 13 commits into from

Conversation

slot
Copy link
Contributor

@slot slot commented Dec 11, 2017

If a service needs a resource (db, cache, queue etc) which can be provided by a dedicated container running this service the developer can add the resource to .missy.yml

Example:

name: demo
resources:
  - "mysql"

The ides is that missy-controller will spin up the needed resources, configure them and place a config in Kubernetes before starting the service. Meaning when the service comes up the dedicated resources are already there and can be used.

Looking at the API for the developer using resources is very simple. @levrik @gizioo @wojciech12 @pbsmacc please critically check this first draft. I used a singleton pattern to hold the current MySQL session but it can be swopped easily during testing.

The code example looks as follows

package main

import (
	"net/http"
	"time"
	"github.com/microdevs/missy/service"
	"github.com/microdevs/missy/resource"
	"github.com/microdevs/missy/log"
)


func main() {

	s := service.New()

	s.HandleFunc("/log", func(w *service.ResponseWriter, r *http.Request) {

		_, err := resource.MysqlConnection().Exec("INSERT into accesslog (accessTime, agent) values (NOW(),?)", r.UserAgent())
		if err!= nil {
			w.Error("DB query failed", http.StatusInternalServerError)
		}
		w.Write([]byte("OK wrote log"))
	}).Methods(http.MethodPost)

	s.Start()
}

Let me know what you think. In the meantime I will prepare the missy-controller to prove the resource spin up flow works.

@slot slot requested a review from wojciech12 December 11, 2017 15:31
case MysqlResourceName:
my := Mysql{}
my.Setup(c)
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we print a warning here for unknown resources?

@mize85
Copy link

mize85 commented Dec 12, 2017

@slot would it make sense to change implementation slightly to allow more than one mysql (or any other) resource ?
e.g. add a type and infer settings from resource name?
or would 2 mysql resources in one service be pfui pfui?

@coveralls
Copy link

Coverage Status

Coverage decreased (-1.2%) to 45.779% when pulling 3b709fe on providing-resources into b0aa3a4 on master.

@GitCop
Copy link

GitCop commented Jan 2, 2018

There were the following issues with your Pull Request

  • Commit: c927b6a

  • Commits must be in the following format: %{type}(%{scope}): %{description}

  • Your subject line is longer than 72 characters

  • Invalid type. Valid types are feat, fix, docs, style, refactor, perf, test, chore, revert

  • Commit: 9c3af65

  • Commits must be in the following format: %{type}(%{scope}): %{description}

  • Commit: eb65525

  • Commits must be in the following format: %{type}(%{scope}): %{description}

  • Commit: 1908ff2

  • Commits must be in the following format: %{type}(%{scope}): %{description}

  • Your subject line is longer than 72 characters

  • Commit: 8666314

  • Commits must be in the following format: %{type}(%{scope}): %{description}

  • Commit: 3b709fe

  • Commits must be in the following format: %{type}(%{scope}): %{description}

  • Commit: 3e69a85

  • Commits must be in the following format: %{type}(%{scope}): %{description}

Guidelines are available at https://github.com/microdevs/missy


This message was auto-generated by https://gitcop.com

@GitCop
Copy link

GitCop commented Jan 2, 2018

There were the following issues with your Pull Request

  • Commit: c927b6a

  • Commits must be in the following format: %{type}(%{scope}): %{description}

  • Your subject line is longer than 72 characters

  • Invalid type. Valid types are feat, fix, docs, style, refactor, perf, test, chore, revert

  • Commit: 9c3af65

  • Commits must be in the following format: %{type}(%{scope}): %{description}

  • Commit: eb65525

  • Commits must be in the following format: %{type}(%{scope}): %{description}

  • Commit: 1908ff2

  • Commits must be in the following format: %{type}(%{scope}): %{description}

  • Your subject line is longer than 72 characters

  • Commit: 8666314

  • Commits must be in the following format: %{type}(%{scope}): %{description}

  • Commit: 3b709fe

  • Commits must be in the following format: %{type}(%{scope}): %{description}

  • Commit: 3e69a85

  • Commits must be in the following format: %{type}(%{scope}): %{description}

  • Commit: 416ea8a

  • Commits must be in the following format: %{type}(%{scope}): %{description}

Guidelines are available at https://github.com/microdevs/missy


This message was auto-generated by https://gitcop.com

@coveralls
Copy link

Coverage Status

Coverage increased (+1.3%) to 48.288% when pulling 416ea8a on providing-resources into b0aa3a4 on master.

@GitCop
Copy link

GitCop commented Jan 2, 2018

There were the following issues with your Pull Request

  • Commit: c927b6a

  • Commits must be in the following format: %{type}(%{scope}): %{description}

  • Your subject line is longer than 72 characters

  • Invalid type. Valid types are feat, fix, docs, style, refactor, perf, test, chore, revert

  • Commit: 9c3af65

  • Commits must be in the following format: %{type}(%{scope}): %{description}

  • Commit: eb65525

  • Commits must be in the following format: %{type}(%{scope}): %{description}

  • Commit: 1908ff2

  • Commits must be in the following format: %{type}(%{scope}): %{description}

  • Your subject line is longer than 72 characters

  • Commit: 8666314

  • Commits must be in the following format: %{type}(%{scope}): %{description}

  • Commit: 3b709fe

  • Commits must be in the following format: %{type}(%{scope}): %{description}

  • Commit: 3e69a85

  • Commits must be in the following format: %{type}(%{scope}): %{description}

  • Commit: 416ea8a

  • Commits must be in the following format: %{type}(%{scope}): %{description}

  • Commit: f6f06d3

  • Commits must be in the following format: %{type}(%{scope}): %{description}

  • Invalid type. Valid types are feat, fix, docs, style, refactor, perf, test, chore, revert

Guidelines are available at https://github.com/microdevs/missy


This message was auto-generated by https://gitcop.com

@coveralls
Copy link

Coverage Status

Coverage increased (+1.3%) to 48.288% when pulling f6f06d3 on providing-resources into b0aa3a4 on master.

@GitCop
Copy link

GitCop commented Jan 2, 2018

There were the following issues with your Pull Request

  • Commit: c927b6a

  • Commits must be in the following format: %{type}(%{scope}): %{description}

  • Your subject line is longer than 72 characters

  • Invalid type. Valid types are feat, fix, docs, style, refactor, perf, test, chore, revert

  • Commit: 9c3af65

  • Commits must be in the following format: %{type}(%{scope}): %{description}

  • Commit: eb65525

  • Commits must be in the following format: %{type}(%{scope}): %{description}

  • Commit: 1908ff2

  • Commits must be in the following format: %{type}(%{scope}): %{description}

  • Your subject line is longer than 72 characters

  • Commit: 8666314

  • Commits must be in the following format: %{type}(%{scope}): %{description}

  • Commit: 3b709fe

  • Commits must be in the following format: %{type}(%{scope}): %{description}

  • Commit: 3e69a85

  • Commits must be in the following format: %{type}(%{scope}): %{description}

  • Commit: 416ea8a

  • Commits must be in the following format: %{type}(%{scope}): %{description}

  • Commit: f6f06d3

  • Commits must be in the following format: %{type}(%{scope}): %{description}

  • Invalid type. Valid types are feat, fix, docs, style, refactor, perf, test, chore, revert

  • Commit: 1039c77

  • Commits must be in the following format: %{type}(%{scope}): %{description}

Guidelines are available at https://github.com/microdevs/missy


This message was auto-generated by https://gitcop.com

@GitCop
Copy link

GitCop commented Jan 2, 2018

There were the following issues with your Pull Request

  • Commit: c927b6a

  • Commits must be in the following format: %{type}(%{scope}): %{description}

  • Your subject line is longer than 72 characters

  • Invalid type. Valid types are feat, fix, docs, style, refactor, perf, test, chore, revert

  • Commit: 9c3af65

  • Commits must be in the following format: %{type}(%{scope}): %{description}

  • Commit: eb65525

  • Commits must be in the following format: %{type}(%{scope}): %{description}

  • Commit: 1908ff2

  • Commits must be in the following format: %{type}(%{scope}): %{description}

  • Your subject line is longer than 72 characters

  • Commit: 8666314

  • Commits must be in the following format: %{type}(%{scope}): %{description}

  • Commit: 3b709fe

  • Commits must be in the following format: %{type}(%{scope}): %{description}

  • Commit: 3e69a85

  • Commits must be in the following format: %{type}(%{scope}): %{description}

  • Commit: 416ea8a

  • Commits must be in the following format: %{type}(%{scope}): %{description}

  • Commit: f6f06d3

  • Commits must be in the following format: %{type}(%{scope}): %{description}

  • Invalid type. Valid types are feat, fix, docs, style, refactor, perf, test, chore, revert

  • Commit: 1039c77

  • Commits must be in the following format: %{type}(%{scope}): %{description}

  • Commit: 24bad59

  • Commits must be in the following format: %{type}(%{scope}): %{description}

Guidelines are available at https://github.com/microdevs/missy


This message was auto-generated by https://gitcop.com

@coveralls
Copy link

Coverage Status

Coverage increased (+1.2%) to 48.113% when pulling 24bad59 on providing-resources into b0aa3a4 on master.

@coveralls
Copy link

Coverage Status

Coverage increased (+1.3%) to 48.288% when pulling 24bad59 on providing-resources into b0aa3a4 on master.

@wojciech12 wojciech12 closed this Mar 22, 2018
@levrik
Copy link
Contributor

levrik commented Mar 22, 2018

@wojciech12 Why closed?

@wojciech12
Copy link
Contributor

@levrik We can reopen it when we go back to discussion about implementing standard clients.

@levrik
Copy link
Contributor

levrik commented Mar 26, 2018

@wojciech12 Can we please just leave it open so we don't forget about it?

@wojciech12
Copy link
Contributor

@levrik if we forget about it, it would mean we did not need it in the first place. So I will keep it close.

@levrik
Copy link
Contributor

levrik commented Mar 26, 2018

@wojciech12 I disagree but okay.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants