components

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2016 License: CC0-1.0 Imports: 3 Imported by: 0

README

Component Development

Overview

Components will evolve over time to incorporate more details and in different ways. However, since this is an actively used tool, it should support all valid component schemas, past and present. The way this is accomplished is by abstracting access to specific versions of components to generic interfaces located in versions/base/component.go.

Development

When creating your component struct, place the appropriate YAML tags on the fields as you would normally for the specific version. Now, whenever you unmarshal your data, it will fill all the fields you want for that version.

Now you must implement the interfaces inside your component structs.

In the case that you want to change how much access you want to give externally, you will need to edit the methods on the interfaces.

Adding A New Version
  1. Create a folder versions/X_Y_Z where the X_Y_Z is the version in semver notation.
  2. Create your Component struct and any other structs that will implement the different interfaces inside here.
  3. Add another variable to represent your version inside of versions/parse.go
  4. Add a check in the switch-case block for your new version that is represented by the variable created in step 3.
    1. Follow the same logic seen in the other versions inside the switch-case block.
  5. Add tests case fixtures with valid and invalid data for your version along with the other fixtures.
  6. Add those cases to the versions/parse_test.go
Editing The Interface
  1. Change the interface(s) inside of interfaces.
  2. Change the implementations for all the component versions (located in versions) to accomodate the interface changes.

For details on the component scheams, consult the schemas repository

tl;dr

All component versions must implement the interface.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Components

type Components struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

Components struct is a thread-safe structure mapping for components

func NewComponents

func NewComponents() *Components

NewComponents creates an instance of Components struct

func (*Components) Add

func (components *Components) Add(component base.Component)

Add adds a new component to the component map

func (*Components) CompareAndAdd

func (components *Components) CompareAndAdd(component base.Component) bool

CompareAndAdd compares to see if the component exists in the map. If not, it adds the component. This function is thread-safe.

func (*Components) Get

func (components *Components) Get(key string) base.Component

Get retrieves a new component from the component map

func (*Components) GetAll

func (components *Components) GetAll() map[string]base.Component

GetAll retrieves all the components

func (*Components) GetAndApply

func (components *Components) GetAndApply(key string, callback func(component base.Component))

GetAndApply get a component and apply the callback function inside while locking components

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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