tutorial

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const INT32CONSTANT = 9853

Variables

View Source
var CalculatorAddResult_Success_DEFAULT int32
View Source
var CalculatorCalculateResult_Success_DEFAULT int32
View Source
var GoUnusedProtection__ int
View Source
var MAPCONSTANT map[string]string
View Source
var Work_Comment_DEFAULT string

Functions

This section is empty.

Types

type Calculator

type Calculator interface {
	shared.SharedService

	// A method definition looks like C code. It has a return type, arguments,
	// and optionally a list of exceptions that it may throw. Note that argument
	// lists and exception lists are specified using the exact same syntax as
	// field lists in struct or exception definitions.
	Ping(ctx context.Context) (_err error)
	// Parameters:
	//  - Num1
	//  - Num2
	Add(ctx context.Context, num1 int32, num2 int32) (_r int32, _err error)
	// Parameters:
	//  - Logid
	//  - W
	Calculate(ctx context.Context, logid int32, w *Work) (_r int32, _err error)
	// This method has a oneway modifier. That means the client only makes
	// a request and does not listen for any response at all. Oneway methods
	// must be void.
	Zip(ctx context.Context) (_err error)
}

type CalculatorAddArgs

type CalculatorAddArgs struct {
	Num1 int32 `thrift:"num1,1" db:"num1" json:"num1"`
	Num2 int32 `thrift:"num2,2" db:"num2" json:"num2"`
}

Attributes:

  • Num1
  • Num2

func NewCalculatorAddArgs

func NewCalculatorAddArgs() *CalculatorAddArgs

func (*CalculatorAddArgs) GetNum1

func (p *CalculatorAddArgs) GetNum1() int32

func (*CalculatorAddArgs) GetNum2

func (p *CalculatorAddArgs) GetNum2() int32

func (*CalculatorAddArgs) Read

func (p *CalculatorAddArgs) Read(ctx context.Context, iprot thrift.TProtocol) error

func (*CalculatorAddArgs) ReadField1

func (p *CalculatorAddArgs) ReadField1(ctx context.Context, iprot thrift.TProtocol) error

func (*CalculatorAddArgs) ReadField2

func (p *CalculatorAddArgs) ReadField2(ctx context.Context, iprot thrift.TProtocol) error

func (*CalculatorAddArgs) String

func (p *CalculatorAddArgs) String() string

func (*CalculatorAddArgs) Write

func (p *CalculatorAddArgs) Write(ctx context.Context, oprot thrift.TProtocol) error

type CalculatorAddResult

type CalculatorAddResult struct {
	Success *int32 `thrift:"success,0" db:"success" json:"success,omitempty"`
}

Attributes:

  • Success

func NewCalculatorAddResult

func NewCalculatorAddResult() *CalculatorAddResult

func (*CalculatorAddResult) GetSuccess

func (p *CalculatorAddResult) GetSuccess() int32

func (*CalculatorAddResult) IsSetSuccess

func (p *CalculatorAddResult) IsSetSuccess() bool

func (*CalculatorAddResult) Read

func (*CalculatorAddResult) ReadField0

func (p *CalculatorAddResult) ReadField0(ctx context.Context, iprot thrift.TProtocol) error

func (*CalculatorAddResult) String

func (p *CalculatorAddResult) String() string

func (*CalculatorAddResult) Write

type CalculatorCalculateArgs

type CalculatorCalculateArgs struct {
	Logid int32 `thrift:"logid,1" db:"logid" json:"logid"`
	W     *Work `thrift:"w,2" db:"w" json:"w"`
}

Attributes:

  • Logid
  • W

func NewCalculatorCalculateArgs

func NewCalculatorCalculateArgs() *CalculatorCalculateArgs

func (*CalculatorCalculateArgs) GetLogid

func (p *CalculatorCalculateArgs) GetLogid() int32

func (*CalculatorCalculateArgs) GetW

func (p *CalculatorCalculateArgs) GetW() *Work

func (*CalculatorCalculateArgs) IsSetW

func (p *CalculatorCalculateArgs) IsSetW() bool

func (*CalculatorCalculateArgs) Read

func (*CalculatorCalculateArgs) ReadField1

func (p *CalculatorCalculateArgs) ReadField1(ctx context.Context, iprot thrift.TProtocol) error

func (*CalculatorCalculateArgs) ReadField2

func (p *CalculatorCalculateArgs) ReadField2(ctx context.Context, iprot thrift.TProtocol) error

func (*CalculatorCalculateArgs) String

func (p *CalculatorCalculateArgs) String() string

func (*CalculatorCalculateArgs) Write

type CalculatorCalculateResult

type CalculatorCalculateResult struct {
	Success *int32            `thrift:"success,0" db:"success" json:"success,omitempty"`
	Ouch    *InvalidOperation `thrift:"ouch,1" db:"ouch" json:"ouch,omitempty"`
}

Attributes:

  • Success
  • Ouch

func NewCalculatorCalculateResult

func NewCalculatorCalculateResult() *CalculatorCalculateResult

func (*CalculatorCalculateResult) GetOuch

func (*CalculatorCalculateResult) GetSuccess

func (p *CalculatorCalculateResult) GetSuccess() int32

func (*CalculatorCalculateResult) IsSetOuch

func (p *CalculatorCalculateResult) IsSetOuch() bool

func (*CalculatorCalculateResult) IsSetSuccess

func (p *CalculatorCalculateResult) IsSetSuccess() bool

func (*CalculatorCalculateResult) Read

func (*CalculatorCalculateResult) ReadField0

func (p *CalculatorCalculateResult) ReadField0(ctx context.Context, iprot thrift.TProtocol) error

func (*CalculatorCalculateResult) ReadField1

func (p *CalculatorCalculateResult) ReadField1(ctx context.Context, iprot thrift.TProtocol) error

func (*CalculatorCalculateResult) String

func (p *CalculatorCalculateResult) String() string

func (*CalculatorCalculateResult) Write

type CalculatorClient

type CalculatorClient struct {
	*shared.SharedServiceClient
}

Ahh, now onto the cool part, defining a service. Services just need a name and can optionally inherit from another service using the extends keyword.

func NewCalculatorClient

func NewCalculatorClient(c thrift.TClient) *CalculatorClient

func NewCalculatorClientProtocol

func NewCalculatorClientProtocol(t thrift.TTransport, iprot thrift.TProtocol, oprot thrift.TProtocol) *CalculatorClient

func (*CalculatorClient) Add

func (p *CalculatorClient) Add(ctx context.Context, num1 int32, num2 int32) (_r int32, _err error)

Parameters:

  • Num1
  • Num2

func (*CalculatorClient) Calculate

func (p *CalculatorClient) Calculate(ctx context.Context, logid int32, w *Work) (_r int32, _err error)

Parameters:

  • Logid
  • W

func (*CalculatorClient) Ping

func (p *CalculatorClient) Ping(ctx context.Context) (_err error)

A method definition looks like C code. It has a return type, arguments, and optionally a list of exceptions that it may throw. Note that argument lists and exception lists are specified using the exact same syntax as field lists in struct or exception definitions.

func (*CalculatorClient) Zip

func (p *CalculatorClient) Zip(ctx context.Context) (_err error)

This method has a oneway modifier. That means the client only makes a request and does not listen for any response at all. Oneway methods must be void.

type CalculatorPingArgs

type CalculatorPingArgs struct {
}

func NewCalculatorPingArgs

func NewCalculatorPingArgs() *CalculatorPingArgs

func (*CalculatorPingArgs) Read

func (*CalculatorPingArgs) String

func (p *CalculatorPingArgs) String() string

func (*CalculatorPingArgs) Write

func (p *CalculatorPingArgs) Write(ctx context.Context, oprot thrift.TProtocol) error

type CalculatorPingResult

type CalculatorPingResult struct {
}

func NewCalculatorPingResult

func NewCalculatorPingResult() *CalculatorPingResult

func (*CalculatorPingResult) Read

func (*CalculatorPingResult) String

func (p *CalculatorPingResult) String() string

func (*CalculatorPingResult) Write

type CalculatorProcessor

type CalculatorProcessor struct {
	*shared.SharedServiceProcessor
}

func NewCalculatorProcessor

func NewCalculatorProcessor(handler Calculator) *CalculatorProcessor

type CalculatorZipArgs

type CalculatorZipArgs struct {
}

func NewCalculatorZipArgs

func NewCalculatorZipArgs() *CalculatorZipArgs

func (*CalculatorZipArgs) Read

func (p *CalculatorZipArgs) Read(ctx context.Context, iprot thrift.TProtocol) error

func (*CalculatorZipArgs) String

func (p *CalculatorZipArgs) String() string

func (*CalculatorZipArgs) Write

func (p *CalculatorZipArgs) Write(ctx context.Context, oprot thrift.TProtocol) error

type InvalidOperation

type InvalidOperation struct {
	WhatOp int32  `thrift:"whatOp,1" db:"whatOp" json:"whatOp"`
	Why    string `thrift:"why,2" db:"why" json:"why"`
}

Structs can also be exceptions, if they are nasty.

Attributes:

  • WhatOp
  • Why
var CalculatorCalculateResult_Ouch_DEFAULT *InvalidOperation

func NewInvalidOperation

func NewInvalidOperation() *InvalidOperation

func (*InvalidOperation) Equals

func (p *InvalidOperation) Equals(other *InvalidOperation) bool

func (*InvalidOperation) Error

func (p *InvalidOperation) Error() string

func (*InvalidOperation) GetWhatOp

func (p *InvalidOperation) GetWhatOp() int32

func (*InvalidOperation) GetWhy

func (p *InvalidOperation) GetWhy() string

func (*InvalidOperation) Read

func (p *InvalidOperation) Read(ctx context.Context, iprot thrift.TProtocol) error

func (*InvalidOperation) ReadField1

func (p *InvalidOperation) ReadField1(ctx context.Context, iprot thrift.TProtocol) error

func (*InvalidOperation) ReadField2

func (p *InvalidOperation) ReadField2(ctx context.Context, iprot thrift.TProtocol) error

func (*InvalidOperation) String

func (p *InvalidOperation) String() string

func (InvalidOperation) TExceptionType

func (InvalidOperation) TExceptionType() thrift.TExceptionType

func (*InvalidOperation) Validate

func (p *InvalidOperation) Validate() error

func (*InvalidOperation) Write

func (p *InvalidOperation) Write(ctx context.Context, oprot thrift.TProtocol) error

type MyInteger

type MyInteger int32

Thrift lets you do typedefs to get pretty names for your types. Standard C style here.

func MyIntegerPtr

func MyIntegerPtr(v MyInteger) *MyInteger

type Operation

type Operation int64

You can define enums, which are just 32 bit integers. Values are optional and start at 1 if not supplied, C style again.

const (
	Operation_ADD      Operation = 1
	Operation_SUBTRACT Operation = 2
	Operation_MULTIPLY Operation = 3
	Operation_DIVIDE   Operation = 4
)

func OperationFromString

func OperationFromString(s string) (Operation, error)

func OperationPtr

func OperationPtr(v Operation) *Operation

func (Operation) MarshalText

func (p Operation) MarshalText() ([]byte, error)

func (*Operation) Scan

func (p *Operation) Scan(value interface{}) error

func (Operation) String

func (p Operation) String() string

func (*Operation) UnmarshalText

func (p *Operation) UnmarshalText(text []byte) error

func (*Operation) Value

func (p *Operation) Value() (driver.Value, error)

type Work

type Work struct {
	Num1    int32     `thrift:"num1,1" db:"num1" json:"num1"`
	Num2    int32     `thrift:"num2,2" db:"num2" json:"num2"`
	Op      Operation `thrift:"op,3" db:"op" json:"op"`
	Comment *string   `thrift:"comment,4" db:"comment" json:"comment,omitempty"`
}

Structs are the basic complex data structures. They are comprised of fields which each have an integer identifier, a type, a symbolic name, and an optional default value.

Fields can be declared "optional", which ensures they will not be included in the serialized output if they aren't set. Note that this requires some manual management in some languages.

Attributes:

  • Num1
  • Num2
  • Op
  • Comment
var CalculatorCalculateArgs_W_DEFAULT *Work

func NewWork

func NewWork() *Work

func (*Work) Equals

func (p *Work) Equals(other *Work) bool

func (*Work) GetComment

func (p *Work) GetComment() string

func (*Work) GetNum1

func (p *Work) GetNum1() int32

func (*Work) GetNum2

func (p *Work) GetNum2() int32

func (*Work) GetOp

func (p *Work) GetOp() Operation

func (*Work) IsSetComment

func (p *Work) IsSetComment() bool

func (*Work) Read

func (p *Work) Read(ctx context.Context, iprot thrift.TProtocol) error

func (*Work) ReadField1

func (p *Work) ReadField1(ctx context.Context, iprot thrift.TProtocol) error

func (*Work) ReadField2

func (p *Work) ReadField2(ctx context.Context, iprot thrift.TProtocol) error

func (*Work) ReadField3

func (p *Work) ReadField3(ctx context.Context, iprot thrift.TProtocol) error

func (*Work) ReadField4

func (p *Work) ReadField4(ctx context.Context, iprot thrift.TProtocol) error

func (*Work) String

func (p *Work) String() string

func (*Work) Validate

func (p *Work) Validate() error

func (*Work) Write

func (p *Work) Write(ctx context.Context, oprot thrift.TProtocol) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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