Skip to content

A set of spikes, PoC's, etc for a beb composition solution

License

Notifications You must be signed in to change notification settings

jomoespe/webc-spikes

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

38 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

WebC Spikes

A set of spikes and PcC's of ideas tu be used in Webcomposer.

THis project is structured followinf the standard Go project layout.

make test to run all tests.

Requirements

If you dont't have or you don't want to use make, you can run the test with go test ./...

Examples / PoC's / Spikes

Process HTML

process-html are examples of golang.org/x/net/html package.

Different examples to assert...

  • [DONE] How to process specific tags ((by type, attribute value, etc)
  • [DONE] Remove node children.
  • [DONE] Visit concurrently all nodes of a type in an HTML.
  • Change DOM node content.

HTTPTest

httptest is an example of using net/http/httptest package to test http entrypoints.

Created test about:

  • [DONE] A middleware
  • [DONE] A middleware with request context

Config

A test about using TOML as configuration file format, and BurntSushi as TOML parser.

To assert:

  • [DONE] Read a TOML file.
  • [DONE] Set default values.
  • Add more fields in file than defined in struct.
  • Check the status con config object if fails whe marshalling.

Build tags sample

Example of conditional compilation using build tags.

In this example we have a main using a function (Salutation()) from a package, and two implementations for this, one tagged as tag1 and the other tagged as tag2.

Run or build the example

You can run the application for using one of this tags, with -tag parameter.

# run function tagged as tag1
go run -tags tag1 cmd/buildtags/main.go

# run function without tag (tag1 is default)
go run -tags cmd/buildtags/main.go

# run function tagged as tag2
go run -tags tag2 cmd/buildtags/main.go

Also you can build with the same tag:

# run function tagged as tag1
go build -tags tag1 -o buildtags-tag1 cmd/buildtags/main.go

# run function tagged as tag1
go build -tags tag2 -o buildtags-tag2 cmd/buildtags/main.go

Reload application configuration dynamically

Make a program that receives a signal (SIGHUP for example) reload the configuration or restart the application.

Base on:

Build

# with make
make build-reload-config

# without make
go build -o reload-config cmd/reload-config/main.go

Run and check behavior

# Start the program
./reload-config

# in other terminal, find the process and send a SIGHUP signal.
# to ger pid you can use pgrep or pidof, if available
pgrep reload-config | xargs kill -SIGHUP
pidof reload-config | xargs kill -SIGHUP

# to finish the program, sendd the SIGKILL signal or Crtl+C
pgrep reload-config | xargs kill -SIGHUP
pidof reload-config | xargs kill -SIGKILL

License

An sample showing a licence preamble, a build tag, and a package declaration:

// Copyright 2018 Jomoespe. All rights reserved.
// Use of this source code is governed by a WTFPL-style
// license that can be found in the LICENSE file.

// +build someos someotheros thirdos feature1 feature2,!amd64

// Package composer implements a web composer that blah blah blah...
package composer

About

A set of spikes, PoC's, etc for a beb composition solution

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published