Help us shape the future of Go! Take the 2026 Go Developer Survey

hessian

package module
v0.0.0-...-d1b0970 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2016 License: Apache-2.0 Imports: 8 Imported by: 0

README

gohessian

This is a serializer that uses the Hessian protocol, implemented using the Go language. It was designed at Viant Inc. It can be used for many purposes, including with other open source projects, such as CacheStore. Usage is fairly simple.

Features:

  • Use of Hessian Binary Web Service protocol
  • Uses the Go Language
  • Compatible with other projects

Usage:

  • Ensure your Go environment is setup properly
    • Go can be downloaded here
    • Ensure your GOPATH environment variable is properly set. It may be set to colon-separated paths where Go code, packages, and executables may be found.
    • Ensure your 'GOROOT' environment variable is properly set. It may be set to the location of your Go installation.
    • For more details on how to install Go, click here
  • Install with go get github.com/viant/gohessian
  • All test files can be run with 'go test'
  • User guide is located here: http://viant.github.io/gohessian

Latest Version

The latest stable version is GoHessian 1.0.0. GoHessian Code Base: https://github.com/viant/gohessian

The source code is available under the Apache 2.0 license. We are actively looking for contributors. If you have ideas, code, bug reports, or fixes that you would like to contribute, please do so. Pull requests will be handled by Mickey Hsieh.

Credits and Acknowledgements

[GoHessian Creator: Mickey Hsieh]

[Technical Writer: Allen Wang supervised by Mike Yang]

[Open-source Admin: Allen Wang supervised by Mike Yang]

[GoHessian Website: Allen Wang supervised by the Viant Engineering Team ]

For more, check out our website!

Documentation

Overview

decoder implement hessian 2 protocol, It follows java hessian package standard. It assume that you using the java name convention baisca difference between java and go fully qualify java class name is composed of package + class name Go assume upper case of field name is exportable and java did not have that constrain but in general java using camo camlecase. So it did conversion of field name from the first letter of from upper to lower case typMap{string]reflect.Type contain full java package+class name and go relfect.Type must provide in order to correctly decode to galang interface

Index

Constants

View Source
const (
	TAG_READ        = int32(-1)
	ASCII_GAP       = 32
	CHUNK_SIZE      = 4096
	BC_BINARY       = byte('B') // final chunk
	BC_BINARY_CHUNK = byte('A') // non-final chunk

	BC_BINARY_DIRECT  = byte(0x20) // 1-byte length binary
	BINARY_DIRECT_MAX = byte(0x0f)
	BC_BINARY_SHORT   = byte(0x34) // 2-byte length binary
	BINARY_SHORT_MAX  = 0x3ff      // 0-1023 binary

	BC_DATE        = byte(0x4a) // 64-bit millisecond UTC date
	BC_DATE_MINUTE = byte(0x4b) // 32-bit minute UTC date

	BC_DOUBLE = byte('D') // IEEE 64-bit double

	BC_DOUBLE_ZERO  = byte(0x5b)
	BC_DOUBLE_ONE   = byte(0x5c)
	BC_DOUBLE_BYTE  = byte(0x5d)
	BC_DOUBLE_SHORT = byte(0x5e)
	BC_DOUBLE_MILL  = byte(0x5f)

	BC_FALSE = byte('F') // boolean false

	BC_INT = byte('I') // 32-bit int

	INT_DIRECT_MIN = -0x10
	INT_DIRECT_MAX = byte(0x2f)
	BC_INT_ZERO    = byte(0x90)

	INT_BYTE_MIN     = -0x800
	INT_BYTE_MAX     = 0x7ff
	BC_INT_BYTE_ZERO = byte(0xc8)

	BC_END = byte('Z')

	INT_SHORT_MIN     = -0x40000
	INT_SHORT_MAX     = 0x3ffff
	BC_INT_SHORT_ZERO = byte(0xd4)

	BC_LIST_VARIABLE         = byte(0x55)
	BC_LIST_FIXED            = byte('V')
	BC_LIST_VARIABLE_UNTYPED = byte(0x57)
	BC_LIST_FIXED_UNTYPED    = byte(0x58)

	BC_LIST_DIRECT         = byte(0x70)
	BC_LIST_DIRECT_UNTYPED = byte(0x78)
	LIST_DIRECT_MAX        = byte(0x7)

	BC_LONG         = byte('L') // 64-bit signed integer
	LONG_DIRECT_MIN = -0x08
	LONG_DIRECT_MAX = byte(0x0f)
	BC_LONG_ZERO    = byte(0xe0)

	LONG_BYTE_MIN     = -0x800
	LONG_BYTE_MAX     = 0x7ff
	BC_LONG_BYTE_ZERO = byte(0xf8)

	LONG_SHORT_MIN     = -0x40000
	LONG_SHORT_MAX     = 0x3ffff
	BC_LONG_SHORT_ZERO = byte(0x3c)

	BC_LONG_INT = byte(0x59)

	BC_MAP         = byte('M')
	BC_MAP_UNTYPED = byte('H')

	BC_NULL = byte('N')

	BC_OBJECT     = byte('O')
	BC_OBJECT_DEF = byte('C')

	BC_OBJECT_DIRECT  = byte(0x60)
	OBJECT_DIRECT_MAX = byte(0x0f)

	BC_REF = byte(0x51)

	BC_STRING       = byte('S') // final string
	BC_STRING_CHUNK = byte('R') // non-final string

	BC_STRING_DIRECT  = byte(0x00)
	STRING_DIRECT_MAX = byte(0x1f)
	BC_STRING_SHORT   = byte(0x30)
	STRING_SHORT_MAX  = 0x3ff

	BC_TRUE = byte('T')

	P_PACKET_CHUNK = byte(0x4f)
	P_PACKET       = byte('P')

	P_PACKET_DIRECT   = byte(0x80)
	PACKET_DIRECT_MAX = byte(0x7f)

	P_PACKET_SHORT   = byte(0x70)
	PACKET_SHORT_MAX = 0xfff
	ARRAY_STRING     = "[string"
	ARRAY_INT        = "[int"
	ARRAY_DOUBLE     = "[double"
	ARRAY_FLOAT      = "[float"
	ARRAY_BOOL       = "[boolean"
	ARRAY_LONG       = "[long"
)

Variables

This section is empty.

Functions

func CapitalizeName

func CapitalizeName(name string) string

func NewDecoder

func NewDecoder(r io.Reader, typ map[string]reflect.Type) *decoder

func NewEncoder

func NewEncoder(w io.Writer, np map[string]string) *encoder

Types

type ClassDef

type ClassDef struct {
	FullClassName string
	FieldName     []string
}

type ErrDecoder

type ErrDecoder struct {
	Message string
	Err     error
}

ErrDecoder is returned when the encoder encounters an error.

func (ErrDecoder) Error

func (e ErrDecoder) Error() string

type Serializer

type Serializer interface {
	ToBytes(interface{}) ([]byte, error)
	ToObject([]byte) (interface{}, error)
}

func NewGoHessian

func NewGoHessian(typMap map[string]reflect.Type, nmeMap map[string]string) Serializer

Jump to

Keyboard shortcuts

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