SlideShare a Scribd company logo
1 of 38
Download to read offline
Core Concepts
• flamingo.App
• Dingo
• Config
• Routing
Flamingo Bootstrap
Bootstrap
• Define the configuration Areas

• Load default configuration

• Load the current configuration and routing information

• Load overriding configuration

• Register additional Handlers

• Run the main command / Start a router
flamingo.App
flamingo.App
• Main entry point, starts the Flamingo instance

• Configures dingo dependency injection and runs the root
command
flamingo.App / Changes
• flamingo.App(..., flamingo.AppAutorun(false))

• Allows external control of the App lifecycle
Dingo Modules
Dingo
• Flamingo Dependency Injection

• Interface similar to Guice

• Supports Singleton, Multi-/Mapbindings
Dingo
type HelloController struct {
responder *web.Responder
}
func (c *HelloController) Inject(responder *web.Responder) {
c.responder = responder
}
General
• Bind dependencies on application startup (in code)

• (future support for compile-type bindings)

• Config-Tree based injector-trees: It's possible to inject
different services/adapters for certain configuration areas
Binding
• General Syntax:

injector.Bind(new(Iface)).To(IfaceImpl{})
• .To(type) binds to a type

• .ToInstance(instance) binds to an instance

• .ToProvider(func() instance) binds to a provider
Annotation
• Default annotation is empty

injector.Bind(new(Iface)).AnnotatedWith("special-case").To(IfaceImpl{})
• Inject via

func (instance *MyType) Inject(annotated *struct{
IfaceInstance Iface `inject:"special-case"`
}) {
instance.iface = annotated.IfaceInstance
}
• Used by configuration for configuration values
Singleton Scopes
• If really necessary it is possible to use singletons

• .AsEagerSingleton() binds as a singleton, and loads it
when the application is initialized

• .In(dingo.Singleton) makes it a global singleton

• .In(dingo.ChildSingleton) makes it a singleton limited to
the config area
MultiBindings
• Allows to bind multiple instances/providers/types for one
type
func (*Module) Configure(injector *dingo.Injector) {
injector.BindMulti(new(Iface)).To(IfaceImpl1{})
injector.BindMulti(new(Iface)).To(IfaceImpl2{})
}
func (*MyService) Inject(ifaces []Iface) {}
MapBindings
• Similiar to Multibindings, but with a key instead of a list
func (*Module) Configure(injector *dingo.Injector) {
injector.BindMap(new(Iface), "key1").To(IfaceImpl1{})
injector.BindMap(new(Iface), "key2").To(IfaceImpl2{})
}
func (*MyService) Inject(ifaces map[string]Iface) {}
Provider
• If you need to make sure bindings are lazy evaluated, or
need multiple instances of a certain type, it is possible to
inject provider

• Define a type which ends with Provider, and gives you
what you need:
type IfaceProvider func() Iface
func (*Service) Inject(provider IfaceProvider) {
ifaceInstance := provider()
}
Provider
• It is possible to get provider for map/multibindings

• It is possible to get provider for provider

• Use with care: this might be an indicator of too complicated
code
Configuration
config.Map
• config.Map is a container for string -> interface{}

• configuration is available via annotated injection

• MyConfig string inject:"config:my.config"
• My config.Map `inject:"config:my"`
• Numbers: int is also float64
Config Merging
• Dot . separated config keys

• Every . donates one level in the tree:
my.config.value: hello
my:
config:
value: hello
Config Merging
• Config Maps are deep merged

• Allows overriding sub-keys:
my:
foo: bar
config:
value: hello
value2: world
my.config.value: myhello
Config Loading
• YAML Loader (others might follow)

• ENV Substitution via %%ENV:something%%default%
%

• config.yml

• config_$CONTEXT.yml

• config_local.yml

• $CONTEXTFILE
Configuration Areas
Configuration Areas
• Flamingo Config is hierarchical

• Config Areas can have multiple children, they inherit
config and dependency injection bindings

• Config is loaded based on file-system layout
Config
Upcoming Changes
• Cuelang support

• Allows Schema validation and much more
Default Configuration
• Modules in Flamingo can provide a default config, and
override existing config during the bootstrap

• The default configuration is loaded before the config
folder

• The override configuration can manipulate configuration
afterwards (use with care!)
Default Configuration
func (m *Module) DefaultConfig() config.Map {
return config.Map{
"my.config.test": "default value",
}
}
Overridden Configuration
func (m *Module) OverrideConfig(current config.Map) config.Map {
if oldvalue, ok := current.Get("my.config.test"); ok {
log.Println("Overriding", oldvalue)
} else {
log.Println("No old value")
}
return config.Map{
"my.config.test": "overriden value",
}
}
Routing
Routing: Paths
• Named Parameters: /route/:name

• Match everything until the following /

• Regex Parameters: /route/$name<[a-z]{2,}>

• Match everything which is captured by the regex (if
possible)

• Wildcard Parameters: /route/*name

• Match everything (everything until the end of the route)
Routing: Controller
• Map a route to a controller, either in routes.yml or in code

• my.controller

• Gets all URL parameters

• my.controller(name="foo")

• Sets name to foo

• my.controller(name?="foo")

• Sets name to foo if not set by a GET parameter

• my.controller(name?)

• Sets name to the value of the name GET parameter, if available
Routing: Reverse
• Reverse URLs are build based on available routes

• web.ReverseRouter

• Newest routes take precendence

• Router parameters are taken into account, meaning:

• /home -> cms.view(page="home")

• url("cms.view", router.P{"page": "home"}) -> /home
web.RouterRegistry
• HandleGet(context.Context, *web.Request) web.Result for
GET

• HandlePost(context.Context, *web.Request) web.Result for
POST

• Same for HEAD, DELETE, PUT

• HandleAny

• HandleData(context.Context, *web.Request) interface{} for
internal data requests
web.RouterRegistry
type routes struct {
controller *controller
}
func (r *routes) Inject(controller *controller) {
r.controller = controller
}
func (r *routes) Routes(registry *web.RouterRegistry) {
registry.Route("/", "home")
registry.HandleAny("home", r.controller.action)
}
core.Prefixrouter
• The core.Prefixrouter module provides a HTTP Router
which routes requests based on hostname/path

• When starting Flamingo the module will create HTTP
listener for all config Areas with a prefixrouter.baseurl
configuration
core.Cmd Package
core.Cmd
• Based on spf13/cobra

• Inject *cobra.Command with annotation flamingo to get
the main command

• Bind to cobra.Command to add custom commands

More Related Content

What's hot

Js interpreter interpreted
Js interpreter interpretedJs interpreter interpreted
Js interpreter interpretedMartha Schumann
 
Managing VMware VMs with Ansible
Managing VMware VMs with AnsibleManaging VMware VMs with Ansible
Managing VMware VMs with Ansiblejtyr
 
Real World Optimization
Real World OptimizationReal World Optimization
Real World OptimizationDavid Golden
 
Virtualize and automate your development environment for fun and profit
Virtualize and automate your development environment for fun and profitVirtualize and automate your development environment for fun and profit
Virtualize and automate your development environment for fun and profitAndreas Heim
 
Basicsof c make and git for a hello qt application
Basicsof c make and git for a hello qt applicationBasicsof c make and git for a hello qt application
Basicsof c make and git for a hello qt applicationDinesh Manajipet
 
Using Grafana with InfluxDB 2.0 and Flux Lang by Jacob Lisi
Using Grafana with InfluxDB 2.0 and Flux Lang by Jacob LisiUsing Grafana with InfluxDB 2.0 and Flux Lang by Jacob Lisi
Using Grafana with InfluxDB 2.0 and Flux Lang by Jacob LisiInfluxData
 
Altitude San Francisco 2018: WebAssembly Tools & Applications
Altitude San Francisco 2018: WebAssembly Tools & ApplicationsAltitude San Francisco 2018: WebAssembly Tools & Applications
Altitude San Francisco 2018: WebAssembly Tools & ApplicationsFastly
 
Devoxx UK 2018 - A cloud application journey with helm and kubernetes
Devoxx UK 2018 - A cloud application journey with helm and kubernetesDevoxx UK 2018 - A cloud application journey with helm and kubernetes
Devoxx UK 2018 - A cloud application journey with helm and kubernetesAna-Maria Mihalceanu
 
RedisGears: Meir Shpilraien
RedisGears: Meir ShpilraienRedisGears: Meir Shpilraien
RedisGears: Meir ShpilraienRedis Labs
 
Flux and InfluxDB 2.0 by Paul Dix
Flux and InfluxDB 2.0 by Paul DixFlux and InfluxDB 2.0 by Paul Dix
Flux and InfluxDB 2.0 by Paul DixInfluxData
 
PyParis2017 / Function-as-a-service - a pythonic perspective on severless com...
PyParis2017 / Function-as-a-service - a pythonic perspective on severless com...PyParis2017 / Function-as-a-service - a pythonic perspective on severless com...
PyParis2017 / Function-as-a-service - a pythonic perspective on severless com...Pôle Systematic Paris-Region
 
Regular expressions, Alex Perry, Google, PyCon2014
Regular expressions, Alex Perry, Google, PyCon2014Regular expressions, Alex Perry, Google, PyCon2014
Regular expressions, Alex Perry, Google, PyCon2014alex_perry
 
Functional Programming with JavaScript
Functional Programming with JavaScriptFunctional Programming with JavaScript
Functional Programming with JavaScriptMark Shelton
 
Optimizing the Grafana Platform for Flux
Optimizing the Grafana Platform for FluxOptimizing the Grafana Platform for Flux
Optimizing the Grafana Platform for FluxInfluxData
 
Take Flight - Using Fly with the Play Framework
Take Flight - Using Fly with the Play FrameworkTake Flight - Using Fly with the Play Framework
Take Flight - Using Fly with the Play FrameworkAsher Glynn
 
GoFFIng around with Ruby #RubyConfPH
GoFFIng around with Ruby #RubyConfPHGoFFIng around with Ruby #RubyConfPH
GoFFIng around with Ruby #RubyConfPHGautam Rege
 

What's hot (20)

C++ programming basics
C++ programming basicsC++ programming basics
C++ programming basics
 
Js interpreter interpreted
Js interpreter interpretedJs interpreter interpreted
Js interpreter interpreted
 
Managing VMware VMs with Ansible
Managing VMware VMs with AnsibleManaging VMware VMs with Ansible
Managing VMware VMs with Ansible
 
Real World Optimization
Real World OptimizationReal World Optimization
Real World Optimization
 
Virtualize and automate your development environment for fun and profit
Virtualize and automate your development environment for fun and profitVirtualize and automate your development environment for fun and profit
Virtualize and automate your development environment for fun and profit
 
Elixir at Evercam (By Milos Mosic)
Elixir at Evercam (By Milos Mosic)Elixir at Evercam (By Milos Mosic)
Elixir at Evercam (By Milos Mosic)
 
Basicsof c make and git for a hello qt application
Basicsof c make and git for a hello qt applicationBasicsof c make and git for a hello qt application
Basicsof c make and git for a hello qt application
 
Using Grafana with InfluxDB 2.0 and Flux Lang by Jacob Lisi
Using Grafana with InfluxDB 2.0 and Flux Lang by Jacob LisiUsing Grafana with InfluxDB 2.0 and Flux Lang by Jacob Lisi
Using Grafana with InfluxDB 2.0 and Flux Lang by Jacob Lisi
 
Altitude San Francisco 2018: WebAssembly Tools & Applications
Altitude San Francisco 2018: WebAssembly Tools & ApplicationsAltitude San Francisco 2018: WebAssembly Tools & Applications
Altitude San Francisco 2018: WebAssembly Tools & Applications
 
Devoxx UK 2018 - A cloud application journey with helm and kubernetes
Devoxx UK 2018 - A cloud application journey with helm and kubernetesDevoxx UK 2018 - A cloud application journey with helm and kubernetes
Devoxx UK 2018 - A cloud application journey with helm and kubernetes
 
RedisGears: Meir Shpilraien
RedisGears: Meir ShpilraienRedisGears: Meir Shpilraien
RedisGears: Meir Shpilraien
 
RedisGears
RedisGearsRedisGears
RedisGears
 
C# 4.0 dynamic
C# 4.0 dynamicC# 4.0 dynamic
C# 4.0 dynamic
 
Flux and InfluxDB 2.0 by Paul Dix
Flux and InfluxDB 2.0 by Paul DixFlux and InfluxDB 2.0 by Paul Dix
Flux and InfluxDB 2.0 by Paul Dix
 
PyParis2017 / Function-as-a-service - a pythonic perspective on severless com...
PyParis2017 / Function-as-a-service - a pythonic perspective on severless com...PyParis2017 / Function-as-a-service - a pythonic perspective on severless com...
PyParis2017 / Function-as-a-service - a pythonic perspective on severless com...
 
Regular expressions, Alex Perry, Google, PyCon2014
Regular expressions, Alex Perry, Google, PyCon2014Regular expressions, Alex Perry, Google, PyCon2014
Regular expressions, Alex Perry, Google, PyCon2014
 
Functional Programming with JavaScript
Functional Programming with JavaScriptFunctional Programming with JavaScript
Functional Programming with JavaScript
 
Optimizing the Grafana Platform for Flux
Optimizing the Grafana Platform for FluxOptimizing the Grafana Platform for Flux
Optimizing the Grafana Platform for Flux
 
Take Flight - Using Fly with the Play Framework
Take Flight - Using Fly with the Play FrameworkTake Flight - Using Fly with the Play Framework
Take Flight - Using Fly with the Play Framework
 
GoFFIng around with Ruby #RubyConfPH
GoFFIng around with Ruby #RubyConfPHGoFFIng around with Ruby #RubyConfPH
GoFFIng around with Ruby #RubyConfPH
 

Similar to Flamingo Core Concepts

Porting legacy apps to Griffon
Porting legacy apps to GriffonPorting legacy apps to Griffon
Porting legacy apps to GriffonJames Williams
 
服务框架: Thrift & PasteScript
服务框架: Thrift & PasteScript服务框架: Thrift & PasteScript
服务框架: Thrift & PasteScriptQiangning Hong
 
Angular for Java Enterprise Developers: Oracle Code One 2018
Angular for Java Enterprise Developers: Oracle Code One 2018Angular for Java Enterprise Developers: Oracle Code One 2018
Angular for Java Enterprise Developers: Oracle Code One 2018Loiane Groner
 
Introduction to Griffon
Introduction to GriffonIntroduction to Griffon
Introduction to GriffonJames Williams
 
Qubell — Component Model
Qubell — Component ModelQubell — Component Model
Qubell — Component ModelRoman Timushev
 
iOS 2 - The practical Stuff
iOS 2 - The practical StuffiOS 2 - The practical Stuff
iOS 2 - The practical StuffPetr Dvorak
 
SF Grails - Ratpack - Compact Groovy Webapps - James Williams
SF Grails - Ratpack - Compact Groovy Webapps - James WilliamsSF Grails - Ratpack - Compact Groovy Webapps - James Williams
SF Grails - Ratpack - Compact Groovy Webapps - James WilliamsPhilip Stehlik
 
ASP.Net 5 and C# 6
ASP.Net 5 and C# 6ASP.Net 5 and C# 6
ASP.Net 5 and C# 6Andy Butland
 
App development with quasar (pdf)
App development with quasar (pdf)App development with quasar (pdf)
App development with quasar (pdf)wonyong hwang
 
TypeScript for Java Developers
TypeScript for Java DevelopersTypeScript for Java Developers
TypeScript for Java DevelopersYakov Fain
 
PTW Rails Bootcamp
PTW Rails BootcampPTW Rails Bootcamp
PTW Rails BootcampMat Schaffer
 
Code is not text! How graph technologies can help us to understand our code b...
Code is not text! How graph technologies can help us to understand our code b...Code is not text! How graph technologies can help us to understand our code b...
Code is not text! How graph technologies can help us to understand our code b...Andreas Dewes
 
ITT 2014 - Peter Steinberger - Architecting Modular Codebases
ITT 2014 - Peter Steinberger - Architecting Modular CodebasesITT 2014 - Peter Steinberger - Architecting Modular Codebases
ITT 2014 - Peter Steinberger - Architecting Modular CodebasesIstanbul Tech Talks
 
A Recovering Java Developer Learns to Go
A Recovering Java Developer Learns to GoA Recovering Java Developer Learns to Go
A Recovering Java Developer Learns to GoMatt Stine
 
How to Build a Telegraf Plugin by Noah Crowley
How to Build a Telegraf Plugin by Noah CrowleyHow to Build a Telegraf Plugin by Noah Crowley
How to Build a Telegraf Plugin by Noah CrowleyInfluxData
 
Building a Telegraf Plugin by Noah Crowly | Developer Advocate | InfluxData
Building a Telegraf Plugin by Noah Crowly | Developer Advocate | InfluxDataBuilding a Telegraf Plugin by Noah Crowly | Developer Advocate | InfluxData
Building a Telegraf Plugin by Noah Crowly | Developer Advocate | InfluxDataInfluxData
 
Angular 1.6 typescript application
Angular 1.6 typescript applicationAngular 1.6 typescript application
Angular 1.6 typescript applicationYitzchak Meirovich
 
Facebook C++网络库Wangle调研
Facebook C++网络库Wangle调研Facebook C++网络库Wangle调研
Facebook C++网络库Wangle调研vorfeed chen
 

Similar to Flamingo Core Concepts (20)

Porting legacy apps to Griffon
Porting legacy apps to GriffonPorting legacy apps to Griffon
Porting legacy apps to Griffon
 
服务框架: Thrift & PasteScript
服务框架: Thrift & PasteScript服务框架: Thrift & PasteScript
服务框架: Thrift & PasteScript
 
What is your money doing?
What is your money doing?What is your money doing?
What is your money doing?
 
Angular for Java Enterprise Developers: Oracle Code One 2018
Angular for Java Enterprise Developers: Oracle Code One 2018Angular for Java Enterprise Developers: Oracle Code One 2018
Angular for Java Enterprise Developers: Oracle Code One 2018
 
Introduction to Griffon
Introduction to GriffonIntroduction to Griffon
Introduction to Griffon
 
Qubell — Component Model
Qubell — Component ModelQubell — Component Model
Qubell — Component Model
 
iOS 2 - The practical Stuff
iOS 2 - The practical StuffiOS 2 - The practical Stuff
iOS 2 - The practical Stuff
 
SF Grails - Ratpack - Compact Groovy Webapps - James Williams
SF Grails - Ratpack - Compact Groovy Webapps - James WilliamsSF Grails - Ratpack - Compact Groovy Webapps - James Williams
SF Grails - Ratpack - Compact Groovy Webapps - James Williams
 
ASP.Net 5 and C# 6
ASP.Net 5 and C# 6ASP.Net 5 and C# 6
ASP.Net 5 and C# 6
 
App development with quasar (pdf)
App development with quasar (pdf)App development with quasar (pdf)
App development with quasar (pdf)
 
TypeScript for Java Developers
TypeScript for Java DevelopersTypeScript for Java Developers
TypeScript for Java Developers
 
PTW Rails Bootcamp
PTW Rails BootcampPTW Rails Bootcamp
PTW Rails Bootcamp
 
Python, do you even async?
Python, do you even async?Python, do you even async?
Python, do you even async?
 
Code is not text! How graph technologies can help us to understand our code b...
Code is not text! How graph technologies can help us to understand our code b...Code is not text! How graph technologies can help us to understand our code b...
Code is not text! How graph technologies can help us to understand our code b...
 
ITT 2014 - Peter Steinberger - Architecting Modular Codebases
ITT 2014 - Peter Steinberger - Architecting Modular CodebasesITT 2014 - Peter Steinberger - Architecting Modular Codebases
ITT 2014 - Peter Steinberger - Architecting Modular Codebases
 
A Recovering Java Developer Learns to Go
A Recovering Java Developer Learns to GoA Recovering Java Developer Learns to Go
A Recovering Java Developer Learns to Go
 
How to Build a Telegraf Plugin by Noah Crowley
How to Build a Telegraf Plugin by Noah CrowleyHow to Build a Telegraf Plugin by Noah Crowley
How to Build a Telegraf Plugin by Noah Crowley
 
Building a Telegraf Plugin by Noah Crowly | Developer Advocate | InfluxData
Building a Telegraf Plugin by Noah Crowly | Developer Advocate | InfluxDataBuilding a Telegraf Plugin by Noah Crowly | Developer Advocate | InfluxData
Building a Telegraf Plugin by Noah Crowly | Developer Advocate | InfluxData
 
Angular 1.6 typescript application
Angular 1.6 typescript applicationAngular 1.6 typescript application
Angular 1.6 typescript application
 
Facebook C++网络库Wangle调研
Facebook C++网络库Wangle调研Facebook C++网络库Wangle调研
Facebook C++网络库Wangle调研
 

More from i-love-flamingo

Flamingo Commerce Module Details
Flamingo Commerce Module DetailsFlamingo Commerce Module Details
Flamingo Commerce Module Detailsi-love-flamingo
 
Flamingo Commerce Ports and Adapters
Flamingo Commerce Ports and AdaptersFlamingo Commerce Ports and Adapters
Flamingo Commerce Ports and Adaptersi-love-flamingo
 
Flamingo Microservice based E-Commerce / Motivations,Backgrounds, Short Intro...
Flamingo Microservice based E-Commerce / Motivations,Backgrounds, Short Intro...Flamingo Microservice based E-Commerce / Motivations,Backgrounds, Short Intro...
Flamingo Microservice based E-Commerce / Motivations,Backgrounds, Short Intro...i-love-flamingo
 
Flamingo Hello World Tutorial
Flamingo Hello World TutorialFlamingo Hello World Tutorial
Flamingo Hello World Tutoriali-love-flamingo
 

More from i-love-flamingo (6)

Flamingo Carotene
Flamingo CaroteneFlamingo Carotene
Flamingo Carotene
 
Flamingo Commerce Module Details
Flamingo Commerce Module DetailsFlamingo Commerce Module Details
Flamingo Commerce Module Details
 
Flamingo Commerce Intro
Flamingo Commerce IntroFlamingo Commerce Intro
Flamingo Commerce Intro
 
Flamingo Commerce Ports and Adapters
Flamingo Commerce Ports and AdaptersFlamingo Commerce Ports and Adapters
Flamingo Commerce Ports and Adapters
 
Flamingo Microservice based E-Commerce / Motivations,Backgrounds, Short Intro...
Flamingo Microservice based E-Commerce / Motivations,Backgrounds, Short Intro...Flamingo Microservice based E-Commerce / Motivations,Backgrounds, Short Intro...
Flamingo Microservice based E-Commerce / Motivations,Backgrounds, Short Intro...
 
Flamingo Hello World Tutorial
Flamingo Hello World TutorialFlamingo Hello World Tutorial
Flamingo Hello World Tutorial
 

Recently uploaded

Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝soniya singh
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number SystemsJheuzeDellosa
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxTier1 app
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...gurkirankumar98700
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfkalichargn70th171
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...ICS
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...kellynguyen01
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfjoe51371421
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxbodapatigopi8531
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideChristina Lin
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - InfographicHr365.us smith
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEOrtus Solutions, Corp
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 
Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...aditisharan08
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
 
cybersecurity notes for mca students for learning
cybersecurity notes for mca students for learningcybersecurity notes for mca students for learning
cybersecurity notes for mca students for learningVitsRangannavar
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...Christina Lin
 

Recently uploaded (20)

Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number Systems
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdf
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - Infographic
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
 
Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
 
cybersecurity notes for mca students for learning
cybersecurity notes for mca students for learningcybersecurity notes for mca students for learning
cybersecurity notes for mca students for learning
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
 

Flamingo Core Concepts

  • 2. • flamingo.App • Dingo • Config • Routing
  • 4. Bootstrap • Define the configuration Areas • Load default configuration • Load the current configuration and routing information • Load overriding configuration • Register additional Handlers • Run the main command / Start a router
  • 6. flamingo.App • Main entry point, starts the Flamingo instance • Configures dingo dependency injection and runs the root command
  • 7. flamingo.App / Changes • flamingo.App(..., flamingo.AppAutorun(false)) • Allows external control of the App lifecycle
  • 9. Dingo • Flamingo Dependency Injection • Interface similar to Guice • Supports Singleton, Multi-/Mapbindings
  • 10. Dingo type HelloController struct { responder *web.Responder } func (c *HelloController) Inject(responder *web.Responder) { c.responder = responder }
  • 11. General • Bind dependencies on application startup (in code) • (future support for compile-type bindings) • Config-Tree based injector-trees: It's possible to inject different services/adapters for certain configuration areas
  • 12. Binding • General Syntax: injector.Bind(new(Iface)).To(IfaceImpl{}) • .To(type) binds to a type • .ToInstance(instance) binds to an instance • .ToProvider(func() instance) binds to a provider
  • 13. Annotation • Default annotation is empty injector.Bind(new(Iface)).AnnotatedWith("special-case").To(IfaceImpl{}) • Inject via func (instance *MyType) Inject(annotated *struct{ IfaceInstance Iface `inject:"special-case"` }) { instance.iface = annotated.IfaceInstance } • Used by configuration for configuration values
  • 14. Singleton Scopes • If really necessary it is possible to use singletons • .AsEagerSingleton() binds as a singleton, and loads it when the application is initialized • .In(dingo.Singleton) makes it a global singleton • .In(dingo.ChildSingleton) makes it a singleton limited to the config area
  • 15. MultiBindings • Allows to bind multiple instances/providers/types for one type func (*Module) Configure(injector *dingo.Injector) { injector.BindMulti(new(Iface)).To(IfaceImpl1{}) injector.BindMulti(new(Iface)).To(IfaceImpl2{}) } func (*MyService) Inject(ifaces []Iface) {}
  • 16. MapBindings • Similiar to Multibindings, but with a key instead of a list func (*Module) Configure(injector *dingo.Injector) { injector.BindMap(new(Iface), "key1").To(IfaceImpl1{}) injector.BindMap(new(Iface), "key2").To(IfaceImpl2{}) } func (*MyService) Inject(ifaces map[string]Iface) {}
  • 17. Provider • If you need to make sure bindings are lazy evaluated, or need multiple instances of a certain type, it is possible to inject provider • Define a type which ends with Provider, and gives you what you need: type IfaceProvider func() Iface func (*Service) Inject(provider IfaceProvider) { ifaceInstance := provider() }
  • 18. Provider • It is possible to get provider for map/multibindings • It is possible to get provider for provider • Use with care: this might be an indicator of too complicated code
  • 20. config.Map • config.Map is a container for string -> interface{} • configuration is available via annotated injection • MyConfig string inject:"config:my.config" • My config.Map `inject:"config:my"` • Numbers: int is also float64
  • 21. Config Merging • Dot . separated config keys • Every . donates one level in the tree: my.config.value: hello my: config: value: hello
  • 22. Config Merging • Config Maps are deep merged • Allows overriding sub-keys: my: foo: bar config: value: hello value2: world my.config.value: myhello
  • 23. Config Loading • YAML Loader (others might follow) • ENV Substitution via %%ENV:something%%default% % • config.yml • config_$CONTEXT.yml • config_local.yml • $CONTEXTFILE
  • 25. Configuration Areas • Flamingo Config is hierarchical • Config Areas can have multiple children, they inherit config and dependency injection bindings • Config is loaded based on file-system layout
  • 26. Config Upcoming Changes • Cuelang support • Allows Schema validation and much more
  • 27. Default Configuration • Modules in Flamingo can provide a default config, and override existing config during the bootstrap • The default configuration is loaded before the config folder • The override configuration can manipulate configuration afterwards (use with care!)
  • 28. Default Configuration func (m *Module) DefaultConfig() config.Map { return config.Map{ "my.config.test": "default value", } }
  • 29. Overridden Configuration func (m *Module) OverrideConfig(current config.Map) config.Map { if oldvalue, ok := current.Get("my.config.test"); ok { log.Println("Overriding", oldvalue) } else { log.Println("No old value") } return config.Map{ "my.config.test": "overriden value", } }
  • 31. Routing: Paths • Named Parameters: /route/:name • Match everything until the following / • Regex Parameters: /route/$name<[a-z]{2,}> • Match everything which is captured by the regex (if possible) • Wildcard Parameters: /route/*name • Match everything (everything until the end of the route)
  • 32. Routing: Controller • Map a route to a controller, either in routes.yml or in code • my.controller • Gets all URL parameters • my.controller(name="foo") • Sets name to foo • my.controller(name?="foo") • Sets name to foo if not set by a GET parameter • my.controller(name?) • Sets name to the value of the name GET parameter, if available
  • 33. Routing: Reverse • Reverse URLs are build based on available routes • web.ReverseRouter • Newest routes take precendence • Router parameters are taken into account, meaning: • /home -> cms.view(page="home") • url("cms.view", router.P{"page": "home"}) -> /home
  • 34. web.RouterRegistry • HandleGet(context.Context, *web.Request) web.Result for GET • HandlePost(context.Context, *web.Request) web.Result for POST • Same for HEAD, DELETE, PUT • HandleAny • HandleData(context.Context, *web.Request) interface{} for internal data requests
  • 35. web.RouterRegistry type routes struct { controller *controller } func (r *routes) Inject(controller *controller) { r.controller = controller } func (r *routes) Routes(registry *web.RouterRegistry) { registry.Route("/", "home") registry.HandleAny("home", r.controller.action) }
  • 36. core.Prefixrouter • The core.Prefixrouter module provides a HTTP Router which routes requests based on hostname/path • When starting Flamingo the module will create HTTP listener for all config Areas with a prefixrouter.baseurl configuration
  • 38. core.Cmd • Based on spf13/cobra • Inject *cobra.Command with annotation flamingo to get the main command • Bind to cobra.Command to add custom commands