utils

package
v0.0.11 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2016 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Overview

Copyright 2015 Gravitational, Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2015 Gravitational, Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2015 Gravitational, Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2015 Gravitational, Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2015 Gravitational, Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2015 Gravitational, Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2015 Gravitational, Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2015 Gravitational, Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

View Source
const DefaultLRUCapacity = 1024

Variables

View Source
var NullEventLogger lunk.EventLogger = &NOPEventLogger{}
View Source
var RealTime = &WallClock{}

Functions

func CreateTLSConfiguration

func CreateTLSConfiguration(certString, keyString string) (*tls.Config, error)

func ListenAndServeTLS

func ListenAndServeTLS(address string, handler http.Handler,
	cert, key string) error

func MultiCloser

func MultiCloser(closers ...io.Closer) *multiCloser

MultiCloser implements io.Close, it sequentially calls Close() on each object

func ObjectToStruct

func ObjectToStruct(in interface{}, out interface{}) error

func ReadPath

func ReadPath(path string) ([]byte, error)

func SplitReaders

func SplitReaders(r1 io.Reader, r2 io.Reader) io.Reader

func StartHTTPServer

func StartHTTPServer(addr NetAddr, h http.Handler) error

func WriteArchive

func WriteArchive(root_directory string, w io.Writer) error

Types

type Clock

type Clock interface {
	Now() time.Time
}

type FileNode

type FileNode struct {
	Parent string `json:"parent"`
	Name   string `json:"name"`
	Dir    bool   `json:"bool"`
	Size   int64  `json:"size"`
	Mode   int64  `json:"mode"`
}

type MemoryListener

type MemoryListener struct {
	// contains filtered or unexported fields
}

Memory listener implements net.Listener using net.Conn

func NewMemoryListener

func NewMemoryListener() *MemoryListener

func (*MemoryListener) Accept

func (ml *MemoryListener) Accept() (net.Conn, error)

func (*MemoryListener) Addr

func (ml *MemoryListener) Addr() net.Addr

func (*MemoryListener) Close

func (ml *MemoryListener) Close() error

func (*MemoryListener) Handle

func (ml *MemoryListener) Handle(conn net.Conn) error

type NOPEventLogger

type NOPEventLogger struct {
}

func (*NOPEventLogger) Log

type NetAddr

type NetAddr struct {
	Addr        string
	AddrNetwork string
	Path        string
}

func ParseAddr

func ParseAddr(a string) (*NetAddr, error)

func (*NetAddr) FullAddress

func (a *NetAddr) FullAddress() string

FullAddress returns full address including network and address (tcp://0.0.0.0:1243)

func (*NetAddr) IsEmpty

func (a *NetAddr) IsEmpty() bool

func (*NetAddr) Network

func (a *NetAddr) Network() string

func (*NetAddr) Set

func (a *NetAddr) Set(s string) error

func (*NetAddr) String

func (a *NetAddr) String() string

String returns address without network (0.0.0.0:1234)

func (*NetAddr) UnmarshalYAML

func (a *NetAddr) UnmarshalYAML(unmarshal func(interface{}) error) error

type NetAddrList

type NetAddrList struct {
	// contains filtered or unexported fields
}

func NewNetAddrList

func NewNetAddrList(addrs *[]NetAddr) *NetAddrList

func (*NetAddrList) Set

func (nl *NetAddrList) Set(s string) error

func (*NetAddrList) String

func (nl *NetAddrList) String() string

type NetAddrVal

type NetAddrVal NetAddr

NetAddrVal can be used with flag package

func NewNetAddrVal

func NewNetAddrVal(defaultVal NetAddr, val *NetAddr) *NetAddrVal

func (*NetAddrVal) Get

func (a *NetAddrVal) Get() interface{}

func (*NetAddrVal) Set

func (a *NetAddrVal) Set(s string) error

func (*NetAddrVal) String

func (a *NetAddrVal) String() string

type PipeNetConn

type PipeNetConn struct {
	// contains filtered or unexported fields
}

PipeNetConn implemetns net.Conn from io.Reader,io.Writer and io.Closer

func NewPipeNetConn

func NewPipeNetConn(r io.Reader, w io.Writer, c io.Closer,
	fakelocalAddr net.Addr, fakeRemoteAddr net.Addr) *PipeNetConn

func (*PipeNetConn) Close

func (nc *PipeNetConn) Close() error

func (*PipeNetConn) LocalAddr

func (nc *PipeNetConn) LocalAddr() net.Addr

func (*PipeNetConn) Read

func (nc *PipeNetConn) Read(buf []byte) (n int, e error)

func (*PipeNetConn) RemoteAddr

func (nc *PipeNetConn) RemoteAddr() net.Addr

func (*PipeNetConn) SetDeadline

func (nc *PipeNetConn) SetDeadline(t time.Time) error

func (*PipeNetConn) SetReadDeadline

func (nc *PipeNetConn) SetReadDeadline(t time.Time) error

func (*PipeNetConn) SetWriteDeadline

func (nc *PipeNetConn) SetWriteDeadline(t time.Time) error

func (*PipeNetConn) Write

func (nc *PipeNetConn) Write(buf []byte) (n int, e error)

type TestClock

type TestClock struct {
	N time.Time
}

func (*TestClock) Advance

func (t *TestClock) Advance(d time.Duration)

func (*TestClock) Now

func (t *TestClock) Now() time.Time

type WallClock

type WallClock struct {
}

func (*WallClock) Now

func (*WallClock) Now() time.Time

Jump to

Keyboard shortcuts

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