当前位置: 首页>>代码示例>>Golang>>正文


Golang Message.Payload方法代码示例

本文整理汇总了Golang中github.com/uhoh-itsmaciek/femebe/core.Message.Payload方法的典型用法代码示例。如果您正苦于以下问题:Golang Message.Payload方法的具体用法?Golang Message.Payload怎么用?Golang Message.Payload使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/uhoh-itsmaciek/femebe/core.Message的用法示例。


在下文中一共展示了Message.Payload方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: processIdentMsg

// Process the identity ('I') message, reporting the identity therein.
func processIdentMsg(msgInit msgInit, exit exitFn) string {
	var m core.Message

	msgInit(&m, exit)

	// Read the remote system identifier string
	if m.MsgType() != 'I' {
		exit("expected identification ('I') message, "+
			"but received %c", m.MsgType())
	}

	// hard-coded lengh limit, but it's very generous
	if m.Size() > 10*KB {
		log.Printf("oversized message string, msg size is %d",
			m.Size())
	}

	s, err := buf.ReadCString(m.Payload())
	if err != nil {
		exit("couldn't read identification string: %v",
			err)
	}

	return s
}
开发者ID:heroku,项目名称:pg_logplexcollector,代码行数:26,代码来源:logfebe.go

示例2: processVerMsg

// Read the version message, calling exit if this is not a supported
// version.
func processVerMsg(msgInit msgInit, exit exitFn) {
	var m core.Message

	msgInit(&m, exit)

	if m.MsgType() != 'V' {
		exit("expected version ('V') message, "+
			"but received %c", m.MsgType())
	}

	// hard-coded lengh limit, but it's very generous
	if m.Size() > 10*KB {
		log.Printf("oversized message string, msg size is %d",
			m.Size())
	}

	s, err := buf.ReadCString(m.Payload())
	if err != nil {
		exit("couldn't read version string: %v", err)
	}

	if !(strings.HasPrefix(s, "PG-9.0") ||
		strings.HasPrefix(s, "PG-9.1") ||
		strings.HasPrefix(s, "PG-9.2") ||
		strings.HasPrefix(s, "PG-9.3") ||
		strings.HasPrefix(s, "PG-9.4") ||
		strings.HasPrefix(s, "PG-9.5")) ||
		!strings.HasSuffix(s, "/logfebe-1") {
		exit("protocol version not supported: %s", s)
	}
}
开发者ID:heroku,项目名称:pg_logplexcollector,代码行数:33,代码来源:logfebe.go

示例3: readExecuteMessage

func (c *FrontendConnection) readExecuteMessage(msg *fbcore.Message) error {
	statementName, err := fbbuf.ReadCString(msg.Payload())
	if err != nil {
		return err
	}
	if statementName != "" {
		return fmt.Errorf("attempted to use statement name %q; only unnamed statements are supported")
	}
	// ignore maxRowCount
	_, err = fbbuf.ReadInt32(msg.Payload())
	// TODO: ensure we're at the end of the packet
	return err
}
开发者ID:geezer-workshop,项目名称:allas,代码行数:13,代码来源:frontendConnection.go

示例4: readBindMessage

func (c *FrontendConnection) readBindMessage(msg *fbcore.Message) error {
	portalName, err := fbbuf.ReadCString(msg.Payload())
	if err != nil {
		return err
	}
	if portalName != "" {
		return fmt.Errorf("attempted to bind to a named portal %q; only the unnamed portal is supported")
	}
	statementName, err := fbbuf.ReadCString(msg.Payload())
	if err != nil {
		return err
	}
	if statementName != "" {
		return fmt.Errorf("attempted to bind statement %q, even though it has not been parsed yet", statementName)
	}
	numParamFormats, err := fbbuf.ReadInt16(msg.Payload())
	if err != nil {
		return err
	}
	if numParamFormats != 0 {
		return fmt.Errorf("the number of parameter formats (%d) does not match the number of parameters in the query (0)", numParamFormats)
	}
	numParameters, err := fbbuf.ReadInt16(msg.Payload())
	if err != nil {
		return err
	}
	if numParameters != 0 {
		return fmt.Errorf("the number of parameters provided by the client (%d) does not match the number of parameters in the query (0)", numParameters)
	}
	// TODO: ensure we're at the end of the packet
	return nil
}
开发者ID:geezer-workshop,项目名称:allas,代码行数:32,代码来源:frontendConnection.go

示例5: readDescribeMessage

func (c *FrontendConnection) readDescribeMessage(msg *fbcore.Message) (byte, error) {
	typ, err := fbbuf.ReadByte(msg.Payload())
	if err != nil {
		return 0, err
	}
	if typ != 'S' && typ != 'P' {
		return 0, fmt.Errorf("invalid type %q", typ)
	}
	statementName, err := fbbuf.ReadCString(msg.Payload())
	if err != nil {
		return 0, err
	}
	if statementName != "" {
		return 0, fmt.Errorf("tried to use statement/portal name %q; only unnamed statements and portals are supported")
	}
	// TODO: ensure we're at the end of the packet
	return typ, nil
}
开发者ID:geezer-workshop,项目名称:allas,代码行数:18,代码来源:frontendConnection.go

示例6: readParseMessage

func (c *FrontendConnection) readParseMessage(msg *fbcore.Message) (queryString string, err error) {
	statementName, err := fbbuf.ReadCString(msg.Payload())
	if err != nil {
		return "", err
	}
	if statementName != "" {
		return "", fmt.Errorf("attempted to use statement name %q; only unnamed statements are supported")
	}
	queryString, err = fbbuf.ReadCString(msg.Payload())
	if err != nil {
		return "", err
	}
	numParamTypes, err := fbbuf.ReadInt16(msg.Payload())
	if err != nil {
		return "", err
	}
	if numParamTypes != 0 {
		return "", fmt.Errorf("attempted to prepare a statement with %d param types", numParamTypes)
	}
	// TODO: ensure we're at the end of the packet
	return queryString, nil
}
开发者ID:geezer-workshop,项目名称:allas,代码行数:22,代码来源:frontendConnection.go


注:本文中的github.com/uhoh-itsmaciek/femebe/core.Message.Payload方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。